Usman Khawaja made a magnificent resilient hundred before Tim Paine and Nathan Lyon denied Pakistan as Australia produced a monumental rearguard action to draw the first Test in Dubai.
Pakistan needed seven wickets on the final day to go 1-0 up in the two-match series after Australia resumed on 136-3, needing a highly unlikely 462 to win, but Khawaja (141) and Travis Head (72) frustrated them with a fourth-wicket stand of 132.
Khawaja made the highest scoring in the fourth innings of a Test in the United Arab Emirates, spending 524 minutes at the crease - taking him to 767 in total - in a heroic 302-ball knock, but the tourists looked to be heading for defeat when Yasir Shah took three late wickets.
Pakistan had 12.2 overs to claim the two wickets they needed for victory after Yasir (4-114) removed Khawaja, Mitchell Starc and Peter Siddle in quick succession, but Paine (61 not out) and Lyon (5no) dug in under pressure to complete a great escape, Australia closing on 362/8.
Australia collapsed with a whimper in the first innings, but Islamabad-born opener Khawaja - who top scored with 85 in the first innings - batted with remarkable application and skill as he and Head ensured no wickets fell in the morning session.
Pakistan struck twice before tea and although Yasir produced a huge twist late in the day, Paine faced 194 balls in a brilliant captain's knock and Lyon also showed great character to rescue Australia.
Head fell without scoring in his first Test innings but made amends by offering great support for Khawaja, who continued to take a positive approach against the spinners.
Khawaja played with great authority and Head reached his half-century after Pakistan opted against reviewing when he was struck on the pad, replays showing he would have been on his way.
Pakistan felt aggrieved when Khawaja was still there after a sharply turning delivery from Haris Sohail rapped him on the pad, the ball hitting the opener just outside the line of off stump, and Australia moved on to 215-3 at lunch.
Mohammad Hafeez got the elusive breakthrough just after the break, trapping Head bang in front from the first delivery with the new ball to end a gritty 175-ball knock.
Khawaja twice lofted Hafeez down the ground for boundaries which moved him into the 90s and the left hander punched the air as he jumped for joy after a quick single took him to three figures for the sixth time in the longest format.
Marnus Labuschagne danced down the wicket to launch Hafeez for six over mid-off, but paid the price for going back to a quicker leg break from Yasir, who pinned the all-rounder in front of middle stump.
Paine walked to the middle with Australia 252-5 and got his eye in after a shaky start, Khawaja still going strong and looking fresh as they saw it through to tea - Pakistan opener Imam-ul-Haq off the field with his finger in a brace.
Pakistan were out of reviews when Sarfraz Ahmed called for a review for lbw, Paine getting an inside edge on an off break from Bilal Asif, but Yasir ended a 79-run stand by snaring the magnificent Khawaja leg before.
It appeared that Khawaja's tour de force would be in vain as Babar Azam took a brilliant catch at short leg to see the back of Starc and Siddle also fell to Yasir without scoring in the same over.
Lyon and Paine stayed cool under pressure in the heat, though, surviving a few close calls to prevent what looked certain to be a Pakistan win.
|Australia 0 Uzbekistan 0 (aet, 4-2 on penalties): Ryan heroics see holders hobble onwards|
|Halep exit leaves four-way fight to be crowned number one at Australian Open|
|Super Bowl-bound Rams set for London return, Chiefs to face Chargers in Mexico|
|Huddersfield appoint Siewert as Wagner´s replacement|
|Genoa 0 AC Milan 2: Borini and Suso step up with Higuain left out|
|McTominay signs new Manchester United contract|
|Pizzi to stand down after Saudi Arabia elimination|
|Boateng closing in on shock Barcelona switch - reports|
|Catalans to defend Challenge Cup after resolving RFL dispute|
|Djokovic wears down Medvedev to reach last eight|
|Mouratoglou: I knew ´loyal´ Serena would not fire me after US Open turmoil|
|Barcelona B defender Wague accuses Ejea fans of racist abuse|
|I felt like I had been hit by a train - Halep upbeat despite losing Serena battle|
|Arsenal confirm Mislintat departure|
|Icardi will renew, 100 per cent - Wanda Nara offers latest Inter assurance|
|Japan 1 Saudi Arabia 0: Four-time winners send Pizzi´s men out|
|A souvlaki maybe named after him, a growing fan base – Tsitsipas creating Melbourne buzz|
|Barca winger Dembele out for 15 days|
|Strikers blown away by Hurricanes in Adelaide|
|Ireland lose Beirne for England and Scotland clashes|
|´Innate fighter´ Serena says character key to beating Halep|
|Hudson-Odoi ´an outstanding talent´ - Bayern great Ballack hails Chelsea youngster|
|Scotland call up four as hand injury forces Watson out|
|Serena comes through major Halep battle to reach last eight|
|Better than Rafa? Camacho cameo leaves Klopp unconvinced by transfer options|
|England job ´a privileged position´, says Southgate|
|Emery has confidence in Arsenal outcast Ozil|
|Zverev destroys racquet in Aus Open meltdown|
|From Villarreal to Aus Open quarters – Bautista Agut breaks major duck|
|Brees: I plan on being here next year and making another run at it|
|´Unf******-believable bro!´ - Brady stunned after reaching third straight Super Bowl|
|New England find answers, penalty costs Kansas City – three takeaways from Patriots´ win over Chiefs|
|Donald Trump congratulates Brady and Super Bowl-bound Patriots|
|Rose helps Timberwolves down Suns|
|Brady leads Patriots into third straight Super Bowl|
|Osaka overcomes Sevastova to reach quarters|
|Chelsea remain behind Sarri – David Luiz|
|McVay explains Gurley´s limited role in Rams´ win over Saints|
|Southgate hails ´tremendous talent´ Rashford|
|Long earns maiden PGA Tour win at Desert Classic|
|Flanagan resigns as Sharks head coach|
|Rams´ Robey-Coleman admits he committed penalty on controversial no-call|
|NFL admits they blew the call – Saints coach Payton|
|Terrible no-call, Goff shines – three takeaways from Rams´ win over Saints|
|Lonzo Ball to miss 4-6 weeks with ankle sprain|
|Patterson added to Australia Test squad|
|Zuerlein´s overtime kick sinks Saints and sends Rams to Super Bowl|
|It was a clear goal – Valverde dismisses Barca VAR controversy|
|Rashford can emulate Man United greats Ronaldo and Rooney – Solskjaer|
|Karmichael Hunt swaps Reds for Waratahs|
|Barcelona forward Dembele set for tests on sprained ankle|
|Neymar insists Barcelona and Real Madrid links not ´concrete´|
|England trio Nowell, Slade and Cowan-Dickie sign fresh Exeter deals|
|Windies coach Pybus not distracted by detractors|
|Barcelona 3 Leganes 1: Messi and Suarez combine to spare Barca´s blushes|
|I´m sure Michael would be extremely proud - Vettel hails Mick Schumacher|
|Young plays down injury fears for England trio Launchbury, Shields and Hughes|
|Pochettino: Lucas Moura fit for Chelsea clash|
|Ranieri positive on Fulham survival chances despite ´unbelievable´ Spurs loss|
|United Arab Emirates v Kyrgyzstan: Zaccheroni confident in attack|
|South Korea lose Ki to hamstring injury|
|It doesn´t look great - Pochettino to wait on Alli assessment|
|Messi benched as Barcelona face Leganes|
|Dalglish texts me before matches - Van Dijk|
|Patrick Mahomes could sign NFL´s first $200m contract - reports|
|Iran 2 Oman 0: Jahanbakhsh and Dejagah secure last-eight spot|
|Helloooo u remember me? Nkoudou reminds Spurs fans he exists|
|Japan v Saudi Arabia: Pizzi believes Saudis can upset the odds|
|Repsol Honda´s Lorenzo to have surgery on fractured wrist|
|Fulham 1 Tottenham 2: Winks heads late winner after Alli injury|