Pakistan appear to have blown their best opportunity to win a Test in Australia for a generation after Mitch Marsh capitalised on an easy dropped catch to steer the hosts out of a historic collapse at the MCG.
Marsh (96), along with Steve Smith (50), saw off Pakistan’s best in the Boxing Day Test, rescuing their team from 4-16 - Australia's worst start to a Test innings at the MCG since 1911.
The pair put on a 153-run fifth-wicket stand to guide Australia to 6-187 at stumps on day three, a lead of 241.
It puts Australia in the box seat to go 2-0 up in the three-match series and salute for a 16th straight home Test against Pakistan.
But Smith was out to star Pakistan quick Shaheen Afridi (3-58) on the final ball of the day, leaving wicketkeeper Alex Carey (16 not out) to resume with Mitchell Starc on Friday.
Pakistan would have been in full control of the Test had opening batter Abdullah Shafique not put down a simple catch in the slips for the second time in three days.
After dropping David Warner in the third over of the match on day one, Shafique spilled a golden opportunity to dismiss Marsh when Australia were on the ropes at 4-46.
“This might be the difference between winning and losing this game,” Pakistan legend Waqar Younis said in commentary on the Seven Network.
“Pakistan fought so, so hard through all of this match and that catch might cost them this match.”
Pakistan quicks Afridi and Mir Hamza (3-27) caused havoc either side of the lunch break to swing the match in the tourists' favour.
Hamza was on a hat-trick after bowling Warner (6) and Travis Head (first-ball duck) in consecutive deliveries to leave Australia reeling at 4-16.
The devastating spell brought back memories of Pakistan’s heyday when the likes of Waqar Younis, Wasim Akram and Imran Khan terrorised batters with wily swing bowling.
Hamza refused to blame Shafique for putting down a catch that could have set up Pakistan's first Test victory in Australia since 1995.
"Abdullah is one of the best fielders in Pakistan, and dropped catches is part of the game," Hamza said.
The missed chance took the steam out of Pakistan's unlikely charge as Marsh continued his sparkling form since being recalled to the team for the third Test of this year's Ashes.
But in an extraordinary turn of events, Marsh (96) fell just short of his fourth Test century after Salman Ali Agha hung on to a spectacular diving catch in the slips.
"In this game, you hear a lot of people say you need a bit of luck sometimes," Marsh said.
"(I had) a bit of luck being dropped (by Shafique) and I guess a bit of karma with a one-handed screamer to get me out, so this game has a funny way of evening things up."
Smith battled his way to his first Test fifty since the Ashes from 176 balls, the second-slowest half-century of his glittering career.
Warner was given a standing ovation from the MCG crowd after departing the arena in what was his final Test innings at the famous ground ahead of his retirement following next week's series finale in Sydney.
Australia went to lunch at 2-6 after Usman Khawaja (0) and Marnus Labuschagne (4) both fell during a chaotic 15 minutes of play.
Australia were forced to bat for a tricky period before the break on Thursday after Pakistan were bowled out for 264.
Earlier, captain Pat Cummins took his 10th five-wicket haul in Tests to help end Pakistan's innings.
Cummins, who swung the second Test in Australia's favour late on day two, grabbed two wickets on Thursday morning to finish with figures of 5-48.
Pakistan's notoriously brittle tail showed far more resistance than expected to push their overnight score from 6-194 in reply to Australia's 318.
Cummins had tremendous support from spinner Nathan Lyon (4-73), who has the fifth-most Test scalps at the MCG and is showing sign of slowing down after entering the 500-wicket club during the first Test in Perth.