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.
|Mourinho sacked: Real Madrid´s Marcelo lauds ´great coach´ after United exit|
|Unadkat, Varun the top buys at IPL auction|
|Emery prepared to give youth a chance in north London derby|
|BREAKING NEWS: Tottenham extend Vertonghen contract until 2020|
|Panthers safety Reid receives seventh random drug test of 2018|
|Kovac relishing Klopp challenge in Champions League|
|Bancroft to return, teenager Lamichhane to fly the flag for Nepal in Big Bash|
|Liverpool still have plenty of work to do - Klopp|
|Messi ´never imagined´ his success after winning record fifth Golden Shoe|
|WATCH: Timberwolves´ Gibson tries to block shot with his trainer|
|Mourinho sacked: Klopp praises departed Manchester United boss|
|Mourinho sacked: Jose the best Manchester United manager since Ferguson - Gerrard|
|Mourinho sacked: Ferdinand calls for ´fresh ideas´ at Man United|
|Mourinho sacked: The mystique has gone as United spell ends in divorce|
|´He´s an interest not only for us but for many´ - Zola praises rumoured Chelsea target Wilson|
|Mourinho sacked: Pochettino focused on Spurs amid Manchester United rumours|
|Mendis eyes double-century for departing Samaraweera|
|Mourinho sacked: Zola expects Jose to be in another job ´soon´|
|Mourinho sacked: Five reasons it went wrong at Manchester United|
|Mourinho sacked: Jose´s Manchester United record in Opta stats|
|Mourinho sacked: Pogba, Ronaldo and Jose´s biggest bust-ups|
|Mourinho sacked: Blanc, Solskjaer - the men who could steady the United ship short-term|
|Mourinho sacked: The football world reacts|
|Mourinho sacked: What former United stars said after Liverpool loss|
|Mourinho sacked: Where next for the axed Manchester United boss?|
|UEFA to investigate alleged racist incidents at Vidi-Chelsea|
|Australia unchanged for rest of India series|
|Mourinho sacked: Pogba´s tweet a dig at departing Man United boss?|
|Newton left frustrated by shoulder injury as Panthers lose again|
|Mourinho sacked: Pochettino & Zidane lead potential Man Utd replacements|
|Mourinho sacked: Neville urges Man United to go for Pochettino|
|Boylen pleased to see Bulls react to red rag in Thunder fracas|
|Icardi and Inter ´very far´ apart in contract negotiations|
|Mourinho leaves Manchester United|
|Curry humbled by latest milestone|
|Robertson: ´Unbelievable´ Alisson will bounce back from error|
|Curry scores 15,000th regular-season point in Warriors win|
|Rams star Gurley ´day-to-day´ with knee inflammation|
|Saints poised to clinch NFC top seed after topping Panthers|
|Mathews, Mendis centuries frustrate New Zealand|
|Kohli: Relentless Australia deserved victory|
|Relief for Paine and Australia after ending Test drought|
|Australia level series with dominant win over India|
|Libertadores holders River learn group as CONMEBOL boss calls for end to violence|
|Chargers RB Gordon planning to return against Ravens|
|Kobe Bryant visit motivated Browns´ Jabrill Peppers|
|De Bruyne: Fatigue not behind injury woes|
|´That´s not my concern´ - Broncos coach Joseph on job security|
|Lowry on Leonard´s free agency: I just want him to be happy|
|Yankees give Sabathia $500K bonus despite ejection|
|Ronaldo confirmed Juventus interest in January – Mendes|
|Lakers guard Rondo to begin rehab stint in G League|
|Saiz to leave Leeds United for Getafe|
|Whyte thinks Joshua rematch is ´only a matter of time´|
|Greenwood stars as Man United end Chelsea´s FA Youth Cup dominance|
|Panthers tight end Olsen expects ´full recovery´ after surgery|
|Derby County 0 Nottingham Forest 0: Lampard´s men fourth after tense stalemate|
|Clermont lose former All Black Toeava for six months|
|MLS unveils revamped playoff format for 2019 season|
|Ferrari to celebrate Schumacher´s 50th birthday with museum exhibition|
|Rabiot set for PSG exit after cancelling contract talks|
|Pepe departs financially troubled Besiktas|
|Philadelphia Flyers fire coach Dave Hakstol|
|Eagles to start Foles v Texans|
|PSG matches against Montpellier and Dijon rearranged|
|Martial agent clouds long-term future after United trigger extension|
|Zverev to make major final in 2019, predicts Ferrero|
|Canelo, Crawford, Lomachenko and the other pound-for-pound contenders|
|Barcelona boss Valverde admits to Lyon uncertainty|
|Club World Cup: Maverick Quintero gets another chance on the big stage|