Perera made a whirlwind 19-ball 47 not out with five sixes, while Hashim Amla finished not out 72 off 55 balls to help the World XI overhaul a 175-run target and level the three-match series 1-1 before a packed Gaddafi stadium in Lahore.
That left the series intriguingly placed with the final match on Friday, also in Lahore.
Pakistan had registered a 20-run win in Tuesday's first match, which marked the return of international cricket to Pakistan.
Left-hander Perera went on a rampage as the visitors needed 33 off the last two overs, smashing two sixes off the 19th over bowled by Sohail Khan before sealing the match in the last over.
Amla, who scored his seventh international Twenty20 half-century, was the steadier of the two, with two sixes and five fours as he helped Perera add 69 runs for the fourth wicket off just 35 balls.
That partnership lifted the World XI after they lost Tamim Iqbal (23), Tim Paine (10) and skipper Faf du Plessis (20).
"It was a very happy day," said Perera. "Hash (Amla) told me to stay till the last moment because we can catch up. I listened to him and we did really well.
"It's a habit for me to be in the situation like this. This is a dream come true for me playing in this World XI. Thanks to Pakistan's fans for coming out in good numbers."
Pakistan captain Sarfraz Ahmed gave credit to the visitors.
"World XI deserves the credit," said Ahmed. "Amla and Perera kept it till late and did it. Our bowlers are young and this is an occasion for them to learn how to bowl in such situations.
"We were also a little sloppy in the field. The score was good enough but if the execution was better in defending, we would have pulled it off."
Pakistan had scored 174-6 in their 20 overs.
Babar Azam (45), Ahmed Shehzad (43) and Shoaib Malik (39) had good starts but none of them went on to score big, as Pakistan found it tough going on a slow and low pitch after winning the toss.
Opener Fakhar Zaman fell for 21 in the fifth over before Shehzad and Azam steadied the innings with a 59-run stand for the second wicket.
Malik hit two sixes in the last over before holing out off the last delivery of the innings.
During his 23-ball knock Malik became the leading run scorer for Pakistan in Twenty20 international cricket, overhauling Umar Akmal's aggregate of 1,690 runs in 88 matches by two runs. He now has 1,692 in 88 matches.
Perera (2-23) and West Indian spinner Badree (2-31) were the main wicket takers for the visitors.
Ahmed ShehzadBabar Azamgaddafi stadiumHashim Amlalahorepakistanpakistan vs world xiSamuel Badreeshoaib malikThisara PereraWorld XI
First Published: September 13, 2017, 11:17 PM IST