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.
|Hansen to leave All Blacks after World Cup|
|Rapid Vienna 1 Rangers 0: Late Ljubicic winner sends Gerrard´s men out|
|Beckham continues to miss Giants practice with quad injury|
|Vidi 2 Chelsea 2: Giroud spares Sarri´s side in lacklustre draw|
|Paris Saint-Germain and Marseille fixtures among latest Ligue 1 cancellations|
|Santos turn to ex-Argentina boss Sampaoli|
|Muller could miss Champions League last 16 after Tagliafico kick|
|Home hope Bekker out in front at Alfred Dunhill Championship|
|Van Bommel in touch with Robben over PSV reunion|
|Pinarello chief confident over Team Sky future|
|Stade make Ospreys tickets free in tribute to teenager|
|WRC great Loeb seals Hyundai switch|
|Madrid rumours better than sack talk, says Pochettino|
|Nadal to join Federer at 2019 Laver Cup|
|Prigoda smashes world record, Hosszu dethroned in Hangzhou|
|Former Juve CEO Marotta takes over at Inter|
|Glenn to stand down as FA boss next year|
|Muller apologises to Tagliafico for kick to the head|
|Pereira pleads for more Manchester United chances|
|Griffin hails ´phenomenal´ Lowry after Warriors demolition|
|I´ve played with Zidane and Henry, but Messi is something else – Pires|
|Dragons forward Jack de Belin charged with sexual assault|
|Durant: Raptors are the real deal|
|Cocu bids farewell to Fenerbahce after ´mutual agreement´ is made over October sacking|
|Australia unchanged for historic Perth Test|
|Champions League draw: The possible last-16 ties|
|Southee happy to be back on home soil|
|I wouldn´t swap Dembele for Neymar – Pires|
|Canelo ready to risk heavy weather against Fielding|
|Raptors upstage Warriors, Davis leads Pelicans with 44 points|
|India skipper Kohli excited by green Perth wicket|
|PSG? I haven´t decided my future yet – De Jong|
|Marcelo: Real Madrid don´t have attitude problem|
|India pair Ashwin, Rohit ruled out of second Test|
|Kovac: Ajax-Bayern draw was amazing|
|Sims re-signs with Dragons until 2022|
|Derrius Guice injury update: Redskins RB (knee) has rehab setback, undergoes 3 more procedures|
|Emery: Arsenal could sign defender in January|
|Phillies sign McCutchen to three-year deal|
|O´Neal thinks his Lakers teams could ´easily´ beat Warriors|
|A-League to add two clubs by 2020|
|Curry says he was ´obviously joking´ about moon landing comments|
|Now the beautiful part starts – Ronaldo ready for Champions League knockout stage|
|Bayern have a lot more potential – Lewandowski not satisfied despite top spot|
|Lyon star Fekir shares plaudits for Champions League progression|
|Mourinho not surprised by United´s defeat to Valencia|
|Motivation no issue for Benfica, claims Vitoria|
|Lewandowski finishes Champions League group stage as top scorer|
|Mourinho: We scored two goals and lost 2-1!|
|England have a diamond - Guardiola hails City´s Foden|
|Sterling´s carefree display invites us to love football more than others hate|
|Juventus achieved their objective, despite everything going wrong – Allegri|
|Never say never - Schmidt not ruling out All Blacks role|
|Bologna´s winning start ended in BCL|
|Di Francesco critical of Roma performance|
|Shakhtar Donetsk 1 Lyon 1: Fekir fires French side through in Group F|
|Benfica 1 AEK Athens 0: Grimaldo sends hosts out on a high|
|Young Boys 2 Juventus 1: Hoarau double seals famous victory|
|Manchester City 2 Hoffenheim 1: City through as group winners after Sane brace|
|Ajax 3 Bayern Munich 3: Kovac´s men clinch top spot in Amsterdam thriller|
|Valencia 2 Manchester United 1: Jones scores own goal as Red Devils limp through|
|Solari accepts responsibility for Madrid´s heaviest home defeat in Europe|
|WATCH: Rooney backs Rocky ahead of Canelo showdown|
|McLaren to collaborate with Team Bahrain Merida|
|Las Vegas to host 2020 NFL Draft|
|Stade teenager tragically dies after neck injury|
|Cahill may need to leave Chelsea if he wants to play, admits Sarri|
|Viktoria Plzen 2 Roma 1: Chory winner takes hosts into Europa League|
|Real Madrid 0 CSKA Moscow 3: Champions humiliated at Bernabeu|
|Sarri condemns ´disgusting´ Sterling abuse|