A two-wicket over from Mitchell Starc turned the match in Australia’s favour when Pakistan needed 44 to win off just 35 balls.
But if not for a fortunate save by captain Aaron Finch the result of the latest Cricket World Cup thriller might have gone the other way.
After David Warner's 107 helped Australia to 307, Pat Cummins appeared to have Pakistan reeling at 6-160 after he took the key wickets of Imam-ul-Haq (53) and the dangerous Shoaib Malik (0), finishing with 3-33.
But Pakistan's lower order had other ideas, with first Hasan Ali (32 from 15) and then Wahab Riaz (45 off 39) putting their team back in the game.
With the runs required dwindling and Pakistan still holding three wickets up their sleeve, Starc (2-43) removed Wahab and Mohammad Amir in the same over to end Pakistan's hopes.
His dismissal of Wahab was a classic piece of captaincy.
The Pakistani was given not out to a caught behind appeal on field despite strong appeals from a number of fieldsmen.
“Bowler thinks so, (Alex) Carey thinks so, Steve Smith at gully is unsure,” Michael Slater said in commentary.
Finch only turned to the umpire and signalled for a review with one second left on the countdown clock – and it paid off.
Replays showed the ball that had just nipped away from him brushed the edge of the bat to have him out.
“Massive moment in the game. Once again Pakistan getting so close,” Slater said.
Starc then bowled Amir two balls later and Glenn Maxwell finished the job, producing an acrobatic run out of Sarfraz Ahmed (40) the following over.
"It got closer than we would have liked," Cummins said.
"We probably gave them a couple with a bit of width and a bit too full at times. And they batted quite well and were suddenly back in the game."
Nathan Coulter-Nile was improved with the ball to finish 1-53 while Kane Richardson took 2-62 in his World Cup debut.
If Australia had lost the game, they would have been left to rue the end of their batting innings after they looked set for a score closer to 400.
The Aussies fell from 2-223 in the 34th over to be all out 307 some 15 overs later.
Warner's century had marked his first since he returned to the Australian side from his 12-month ban, as he dominated on the drive and punished Pakistan's bowlers whenever they erred in their length.
His 111-ball knock also answered questions about his scoring rate in emphatic fashion, as he and Finch (82) combined for a 146-run opening stand.
But after Glenn Maxwell (20) threw his wicket when he was clean bowled trying to go big, Shaun Marsh (23) and Usman Khawaja (18) both struggled to get going before falling to left-armer Amir (5-30).
"I still think I left a lot out there," Warner said.
"You know, 70 balls to go. And with the weather, trying to build partnerships again, I probably hold responsible for the way we fell apart there."
The result puts Australia second behind New Zealand, with England and India in third and fourth but with games in hand.