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.
|Coleman, Kipchoge and Lyles among IAAF Male World Athlete of the Year shortlist|
|Serena Williams will win slams again sooner or later, says Seles|
|You always want the best – Ter Stegen open to Neymar return|
|Xavi: My teams will never use Mourinho´s style|
|I knew what I got myself into - LeBron appreciates Lakers are a work in progress|
|Mourinho: Ronaldo loves United but he will want to score|
|Cooper completes Rebels move and takes parting shot at Reds coach Thorn|
|Bellerin amazed by ´born champion´ Ozil|
|Penguins, kangaroos and ´Stone Cold´ Steve Austin: Halloween comes early for Trail Blazers|
|Ronaldo gunning for United, Aguero targets double record - Champions League in Opta numbers|
|Ill Vardy couldn´t stomach penalty decision – Puel|
|LeBron´s Lakers lose again, Magic stun Celtics|
|Bartomeu: No Barca return for Neymar, Valverde contracted until 2020|
|Simmons and ´stimulating´ 76ers in NBA Finals mix, says Longley|
|Falcons heap further misery on Giants|
|Vidic hails Ronaldo as ultimate professional ahead of Old Trafford return|
|Warriors´ Cousins nearing NBA return|
|Pogba can´t do the basics – Souness criticises Man United star|
|Messi absence big blow for Barca as Icardi talks up Inter|
|´You can´t cry, that´s true´ – Ronaldo responds to Isco|
|Bartomeu: Barca still competitive without Messi|
|Bills RB McCoy remains in concussion protocol|
|Raiders place Marshawn Lynch on IR|
|Emery calm over title talk after another Arsenal win|
|Green: Warriors have to clean up defensively|
|Mariners say Bolt talks ongoing amid reports contract offer was rejected|
|Proud captain Ozil revels in Arsenal´s ´sexy football´|
|Puel angry over Holding handball|
|Cilic breezes through in Basel, Anderson fights back|
|Ingram: Four-game ban better than we expected|
|Raiders send Cooper to Cowboys for first-round pick|
|Arsenal 3 Leicester City 1: Outstanding Ozil inspires comeback win|
|World Series 2018: Three reasons why the Dodgers will win|
|Yarmolenko out for six months after Achilles surgery|
|World Series 2018: Three reasons why the Red Sox will win|
|Ozil eclipses Klinsmann to become Premier League´s most prolific German|
|Allegri expecting Old Trafford battle against Mourinho´s United|
|Bertens feared she did not belong in Kerber clash|
|Returning Ronaldo expecting ´tough´ game against Manchester United|
|Cristiano Ronaldo confident of clearing his name amid rape allegation|
|Osaka looking to learn from losing start in Singapore|
|Kovac expects tough test against AEK Athens|
|Whyte gives Chisora deadline over rematch|
|Spartak Moscow sack Massimo Carrera|
|Atletico Madrid confirm fresh injury issue for Gimenez|
|Dolberg extends Ajax contract after Real Madrid links|
|Ronaldo an example for Lukaku to follow|
|Bertens battles back to blast past Kerber|
|Ramos apologises for training ground fracas|
|Raikkonen should take heed of Alonso misfortune as F1 career winds down|
|Guardiola wants Manchester City fans to push team to Champions League glory|
|Isco not interested in departed Ronaldo - he didn´t want to be here|
|World Series 2018: Three storylines to watch in Red Sox-Dodgers|
|Neymar focus bad for football - PSG´s Maxwell|
|Marco Ianni charged by FA over Jose Mourinho touchline row|
|Stephens sees off Osaka in see-saw Singapore battle|
|I´m happy at Manchester United - Mourinho dismisses Real Madrid reports|
|Semenya and Asher-Smith head IAAF Female World Athlete of the Year shortlist|
|Mandzukic to miss Manchester United trip|
|I turned down Manchester United to return to Juventus - Bonucci|
|Sanchez out of Manchester United´s clash with Juventus|
|Australia make Short work of run chase in T20 win|
|Brotherly g-love! Tommy Fury follows Tyson into the pros|
|Ozil´s international retirement can help Arsenal - Emery|
|If you sack Lopetegui, you have to sack us all – Isco|
|Lopetegui defiant amid Real Madrid sack reports|
|Sri Lanka spinner Herath to retire after Galle Test|
|Ronaldo returns for Old Trafford welcome amid disquieting noise|
|Garcia claims third Andalucia Valderrama Masters title|
|Ex-England international Waldrom retires|