Babar Azam (L and C) and (R) Imam-ul Haq celebrate after scoring 100 runs during the second ODI at the Gaddafi Cricket Stadium in Lahore on Thursday. AFP / AP
Azam hit an 83-ball 114 and Haq notched a 97-ball 106 as Pakistan chased down a stiff 349-run target with six balls to spare to level the three-match series at 1-1.
Ben McDermott cracked a maiden ODI hundred in Australia's imposing total of 348-8 on a flat Gaddafi Stadium pitch.
The victory is Pakistan's first over Australia since Melbourne in January 2017. In between, they had lost 10 consecutive one-day internationals.
Pakistan's win sets up an intriguing final match at the same venue on Saturday. Australia won the first match by 88 runs on Tuesday, also in Lahore.
Haq, who hit six boundaries and three sixes, put on a robust 118-run opening stand with Fakhar Zaman (67) off 111 balls to set the platform for the chase.
Zaman smashed seven boundaries and two sixes during his 64-ball knock before he was bowled by Marcus Stoinis.
Imam-ul Haq celebrates with teammate Babar Azam (L) after scoring a century. AFP
Undeterred, Haq completed his ninth hundred off 90 balls before he holed out at long-off in spinner Adam Zampa's 35th over. Haq added 111 for the second wicket with Azam off 92 balls.
Azam reached his 15th ODI century with a single off Cameron Green, reaching the mark off 73 balls. He added 80 for the third wicket with Mohammad Rizwan before he was caught off Nathan Ellis with 40 needed off 34 balls.
When Rizwan fell for 23, Pakistan still needed 32 but Khushdil Shah cracked 27 not out with two fours and as many sixes and Iftikhar (eight not out) saw off the target in 49 overs.
Pakistan's previous highest ODI chase was 327 achieved against Bangladesh at Mirpur in 2014.
Earlier, McDermott scored 104 off 108 balls in only his fourth ODI, while Travis Head struck 89 and Marnus Labuschagne hit 59 after Australia were sent in to bat in to bat.
All-rounder Stoinis added the finishing touch with a quickfire 49, with five boundaries and a six.
Pace spearhead Shaheen Shah Afridi — who missed Pakistan's 88-run defeat in the first ODI with a knee injury — gave the home side a breakthrough off the third ball of the innings when he trapped Aaron Finch leg-before without scoring.
But Australia scored at will after that with McDermott and Head adding 162 off 144 balls for the second wicket, hitting boundaries with ease.
Head, who scored 101 on Tuesday, smashed five sixes and six fours before miscuing a sweep off leg-spinner Zahid Mahmood, being caught by Shaheen at short fine-leg.
McDermott added another 74 with Labuschagne, and during that stand hit spinner Khushdil over long-off boundary for six to complete a century off 102 balls.
He was finally caught off pacer Mohammad Wasim.
Despite Alex Carey and Cameron Green falling for five each, Sean Abbott chipped in with a 16-ball 28 to boost the total.
Shaheen finished with 4-63 and Wasim took 2-56, but Pakistan's Iftikhar Ahmed and Khushdil conceded 95 runs in ten overs between them.
Babar Azam and Imam-ul Haq hit steady half centuries before spinner Mohammad Nawaz recorded his best figures as Pakistan beat the West Indies by 120 runs in the second day-night international in Multan.
The Australian squad is understrength after Test captain Pat Cummins, Mitchell Starc and Josh Hazlewood as well as opening batter David Warner are being rested after Australia’s 1-0 victory in the Test series in Pakistan. Glenn Maxwell will miss out after getting married last week...
The series — Australia's first in Pakistan for 24 years — opened with a high scoring stalemate on a featherbed pitch in Rawalpindi before the hosts salvaged a fighting draw in Karachi on the back of an epic 196 from Azam.
The ceremony included keynote speeches praising the outcomes of the 7th edition and its role in supporting and developing the Arab women's sports sector.
Presented by the World Professional Wrestling Hub (WPWH), a total of 10 international stars will be competing in an unforgettable night in the ring.
The campaign aims to integrate sports into charitable work by harnessing sports in serving charity activities during the Holy Month and positively integrating sports events in serving the community, which contributes to supporting social services and humanitarian projects.