Pakistan 349 for 4 (Babar 114, Imam 106) beat Australia 348 for 8 (McDermott 104, Head 89, Labuschagne 59, Afridi 4-63) by six wickets
Captain Babar Azam and Imam-ul-Haq smashed brilliant centuries, as a rejuvenated Pakistan mowed down a record run chase of 349 to spectacularly stay alive in the ODI series against a shorthanded Australia in Lahore.
Pakistan produced their highest successful chase in ODIs to win game two by six wickets with six balls to spare. Babar hit a sublime 114 off 83 balls and in-form Imam made 106 off 97 in a record chase for any team in Pakistan.
After an 88-run loss on Tuesday, Pakistan were staring down the barrel of a straight sets series defeat after Australia racked up a mammoth 348 for 8 marked by Ben McDermott's 104 off 108 balls in his first international century.
Playing with more urgency than in game one, Pakistan made the most of batting-friendly conditions and a second string Australian attack which struggled against the onslaught amid a boisterous crowd eager for the hosts to end their barren run during Australia's tour.
A steely Babar provided a masterclass in chasing and he had a point to prove after strangely batting conservatively in the opening game. After notching his 15th ODI century, where he memorably celebrated with a leap and loud roar, Babar became the first Pakistan captain to score an ODI ton against Australia.
With a mixture of sweet timing and power, Babar made the daunting chase look relatively easy to square the series ahead of the decider on Saturday. He was well supported by Imam, who laid the platform in his fourth century so far on Australia's tour.
It was a reality check for Australia, who had produced an almost faultless performance to conjure a stunning upset in game one but their inexperienced attack was under siege throughout. And they will rue losing late wickets with the bat after looking set for a total near 400.
Much like their ham-fisted chase on Tuesday, Pakistan started slowly with opener Fakhar Zaman uncharacteristically shackled. He almost holed out on the boundary to a superb juggling catch by Marcus Stoinis only to be reprieved when the fielder stepped on the rope.
It sparked Fakhar who reached his half-century with a six after charging Travis Head's part-time offspin. Fakhar was in a belligerent mood but out of nowhere Stoinis bowled him with a pearler of a slower delivery that gripped and clipped off stump to leave the crowd stunned. But the fans quickly regained their voice with the entry of Babar, who was in glorious form from the get go and pierced the gaps with ease.
Unlike in the first game, where he seemed to be in cruise control, Babar played with bravado marked by a miscued slog sweep off legspinner Adam Zampa that still sailed for six. He combined well with Imam who became the first Pakistan batter to score consecutive hundreds against Australia in ODIs. He celebrated with an emotional fist pump before falling shortly after but Babar's unwavering confidence had Pakistan charging towards victory.
Babar appeared impregnable until miscuing to midwicket in the 45th over with Pakistan still needing 40 runs for victory and their nerves heightened when Mohammad Rizwan fell in the next over. But Khushdil Shah hit several timely blows to get Pakistan over the line.
It was a remarkable turnaround for Pakistan after Babar had seemed set to regret bowling first for the second straight game. McDermott replicated his BBL big-hitting exploits to repay the faith after being granted a number of opportunities in the shorter formats.
Much like his maiden ODI half-century on Tuesday, McDermott played himself in before mimicking his BBL destructiveness and demonstrating his power hitting. He reached his century in style with a thumping six off spinner Khushdil down the ground as he embraced Marnus Labuschagne with a bear hug and then took his helmet off in triumph.
It was made even more special with his dad Craig McDermott, the former Australia quick, having taken his first ODI five-wicket haul against Pakistan in Lahore in 1987.
McDermott's superb innings ended tamely when he smashed a full toss to midwicket in the 35th over but Stoinis provided the finishing touches with 49 off 33 balls.
Australia's huge innings was set up by McDermott's 162-run second-wicket partnership with Travis Head, who made 89 off 70 balls after his spectacular 101 in game one.
McDermott and Head are making compelling cases for permanent positions heightening the pressure on struggling Australia captain Aaron Finch, who fell for a golden duck - lbw to a Shaheen Shah Afridi full toss - having laboured through the Australian summer with a knee injury.
In the meantime, Finch has a challenge to regroup an undermanned Australia whose 10-match ODI winning streak against Pakistan ended in stunning fashion.