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.
|Thunder´s Westbrook: ´When we defend like that — best team in the league´|
|Kante at his best further forward, reiterates Sarri|
|Rose capitulates in Indonesia to squander chance to top rankings|
|Fielding: The better man won but I lived a dream|
|Rallying Bulls stun Spurs, LeBron and Ball post triple-doubles|
|Latham century puts New Zealand in commanding position|
|Mayfield leads Browns past Broncos|
|Canelo-GGG trilogy? We can make it happen – Alvarez|
|Canelo outclasses Fielding by third-round TKO|
|Farmer retains title prior to Canelo-Fielding bout|
|Qatar unveils Lusail Stadium for 2022 World Cup|
|Lakers pair LeBron, Ball revel in triple-double feat|
|Allegri hails ´great professional´ Ronaldo|
|LeBron, Ball first Lakers team-mates with triple-doubles in same game since 1982|
|Premier League contenders Liverpool ready to win titles – Henderson|
|Hopkins´ two TDs help Texans close in on AFC South title with win over Jets|
|Courtois: Simeone criticises Real Madrid to boost popularity|
|Mourinho in the dark over transfers as Pogba rumours swirl again|
|Mourinho marvels at Salah going nuclear|
|The lucky ones - Mourinho assesses Liverpool´s title charge|
|Juventus boss Allegri turned his back on Ronaldo penalty|
|Dickerson hoping Barkley falls short of breaking his records|
|Bristol shock La Rochelle, Clermont win again|
|LeBron: Meeting Jordan for first time was godly|
|Ronaldo scores Juventus´ 5,000th Serie A goal|
|I was all over the place - Allen reaches Scottish Open final despite hangovers|
|Solari defends wasteful Asensio after slim Madrid win|
|Torino 0 Juventus 1: Ronaldo capitalises on Zaza woe|
|I do my work on the pitch – Icardi unconcerned by Inter contract discussions|
|Lyon defender Rafael set for three months out|
|Inter captain Icardi is the ´perfect´ striker – Spalletti|
|Fulham have to stick together, says Ranieri|
|Nuno hails ´very special´ Wolves achievement after third straight win|
|Stuttgart captain Gentner´s father dies at Hertha fixture|
|Valverde not desperate for new centre-back amid talk of Christensen loan|
|Toulouse and Saracens stay perfect in Champions Cup|
|Kovac lauds Bayern´s best performance of the season|
|Barcelona can get the best out of Coutinho and Dembele, claims Valverde|
|Borussia Dortmund 2 Werder Bremen 1: Alcacer and Reus guarantee top spot for mid-season break|
|Bristol City 2 Norwich City 2: Canaries knocked off their perch despite late equaliser|
|Atletico´s fighting spirit lauded by Simeone, Godin|
|Hodgson relieved to see Palace end Zaha curse|
|Real Madrid 1 Rayo Vallecano 0: Benzema secures steady response to CSKA loss|
|Fulham 0 West Ham 2: Snodgrass, Antonio punish profligate hosts|
|Warnock brands refereeing situation ´a disgrace´ after Watford defeat|
|Inter 1 Udinese 0: Icardi penalty gets lethargic Nerazzurri back on track|
|Wagner retains belief in survival bid despite Newcastle defeat|
|Griezmann feeling the strain after busy 2018|
|Pochettino ´so pleased´ as tired Tottenham scrap to Burnley win|
|Man Utd hand Smalling new contract|
|ES Tunis 0 Al Ain 3: Convincing victory books River Plate semi|
|Championship Review: Bamford fires Leeds to summit, Middlesbrough defeated by QPR|
|Curry reacts to Kings´ trolling with moon landing video|
|Wentz ruled out of Rams clash|
|Pochettino reaches 100 Premier League wins for Tottenham faster than Wenger for Arsenal|
|Real Valladolid 2 Atletico Madrid 3: Griezmann the hero on landmark appearance|
|Silva rues Richarlison´s missed chances at City|
|Gibson has no worries over Proteas batsmen|
|Wolves 2 Bournemouth 0: Jimenez and Cavaleiro score against toothless Cherries|
|Crystal Palace 1 Leicester City 0: Captain Milivojevic earns vital victory|
|Watford 3 Cardiff City 2: Hornets hang on despite late fightback|
|Tottenham 1 Burnley 0: Eriksen snatches victory at the death|
|Huddersfield Town 0 Newcastle United 1: Rondon strike settles scrap|
|Sabres suspend forward Berglund for failing to report to the team|
|Saunders thanks Fury for getting him ´back on the right track´|
|Hannover 0 Bayern Munich 4: Gnabry and Kimmich star in crushing win|
|I admire Sterling – Guardiola|
|City´s strength in depth makes it hard for me – Jesus|
|Jamieson holds slender lead in Malelane|
|Kashima Antlers 3 Guadalajara 2: Comeback win sets up Real Madrid semi-final|