Pakistan completed their highest successful run chase in one-day internationals when they chased down a mammoth target of 349 to beat Australia by six wickets in Lahore to level the series at 1-1 on Thursday.
Centuries from skipper Babar Azam (114) and opener Imam-ul-Haq (106) allowed the hosts to reach the total on a pitch that aided batting.
Imam and Fakhar Zaman (67) gave Pakistan a solid foundation with an opening stand of 118 before Babar walked on and helped Imam build another century partnership as Australia, who used seven bowlers in total, failed to contain the flow of runs.
Pakistan still needed to score 70 off the last 10 overs and when they lost Babar in the 45th over, Mohammad Rizwan kept the score ticking over before he was dismissed for 23, leaving worried faces in the crowd as the required run rate crept up.
But Khushdil Shah (27 off 17) lifted spirits again with a late cameo, changing the equation by smashing two sixes and two boundaries to guide Pakistan to victory with an over to spare.
Earlier, Pakistan chose to field after winning the toss and the hosts made a dream start when Australia captain Aaron Finch was dismissed by Shaheen Shah Afridi in the first over for a duck, trapped leg before wicket.
But Ben McDermott brought up his maiden century (104) and built a 162-run stand with Travis Head (89) while Marnus Labuschagne chipped in with a knock of 59.
Marcus Stoinis also contributed with a handy 49 off 33 balls to help Australia post a total of 348-8.
Afridi was the pick of the bowlers with figures of 4-63 but Pakistan's three spinners had a tough time and were smashed for 166 runs in 20 overs.
Australia won the first ODI by 88 runs. The final ODI will also be played in Lahore on Saturday.