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.
|Kohli and Rahane combine to thwart Australia in Perth|
|Modric cool on Madrid future beyond current deal|
|´Fatigued´ Embiid has a lot on his shoulders - Brown|
|Crespo agrees to take charge at Banfield|
|Westbrook on Murray scuffle: He was in my way|
|Liverpool v Manchester United: Van Dijk the rock on which Klopp can build a title triumph|
|Marcelo ´never´ considered Madrid exit amid Juventus links|
|Liverpool v Manchester United: Resurgent Rashford now a leader for Mourinho|
|Injury-plagued Nuggets beat Thunder to hold Western Conference lead|
|Southee takes five as Sri Lanka recover in Wellington|
|Kings troll Curry by playing clips of moon landing|
|Guardiola: Premier League title race similar to Barca-Madrid battles|
|Ovechkin joins rare NHL club with second straight hat-trick|
|Liverpool can´t be judged just on trophies – Klopp responds to Mourinho|
|Athletics´ Chapman undergoes procedure on left shoulder|
|Marcelo: Real Madrid miss Ronaldo|
|Ronaldo right about Juventus team spirit – Allegri|
|Klopp: I´m not the pope of football tactics|
|Stade beat Ospreys on emotional Chauvin tribute night|
|Ligue 1 survival bid a marathon not a sprint for Monaco, as club appoints distance runner|
|Vertonghen eyeing Spurs future beyond 2020|
|De Bruyne injuries could be a blessing for City, says Guardiola|
|Emery prepared to face Arsenal´s centre-back crisis|
|Ulster complete Scarlets double, Exeter gain Gloucester revenge|
|Sheffield United 1 West Brom 2: Baggies comeback boosts automatic promotion push|
|Del Potro back on court following knee injury|
|Canelo v Fielding: Rocky ready to write his own fairytale in New York|
|Boca part company with Schelotto after Copa Libertadores loss to River|
|Canelo v Fielding: Tale of the tape|
|Juventus defender Cancelo has knee surgery|
|Canelo v Fielding: Alvarez and Rocky make weight in New York|
|Spalletti does not fear another mid-season crisis at Inter|
|Salah headlines CAF Player of the Year shortlist as Koulibaly misses out|
|Beckham Jr. out of Titans clash|
|Lipsky hits the front at Leopard Creek|
|Pederson coy over Wentz back injury|
|Liverpool ´not really likely´ to be active in January window, reveals Klopp|
|Always on the move and unpredictable - Pavard reveals surprising choice over toughest opponent|
|We need to get back to respect - Lampard alarmed by hate in football|
|Giles returns to England to replace Strauss as director|
|Hansen has no issue with Milner-Skudder Toulon switch|
|Juventus to rest Ronaldo after Torino showdown|
|Titmus strikes gold again as world records tumble in Hangzhou|
|Malinga to captain Sri Lanka in New Zealand|
|Rivaldo would like ´excellent´ Isco at Barcelona|
|United a long way from Mourinho´s vision|
|´Klopp denies an answer!´ - Liverpool boss dismisses questions about ´world-class´ Pogba|
|Returning Nowitzki ´so tired´ after making NBA history|
|Aguero and De Bruyne in contention for Manchester City v Everton|
|Simeone has no plans to cash in on Costa|
|Canelo v Fielding: Alvarez´s greatest nights|
|Fabregas: Chelsea being unfairly scapegoated over racism allegations|
|Crisis? What crisis? Klopp focuses on defensive solutions for United clash|
|Hope cannot inspire Windies as Bangladesh cruise to series win|
|Benitez picks up Premier League Manager of the Month award|
|Chavez, Marquez and Canelo - Mexico´s greatest multi-weight world champions|
|Bale set to miss Real Madrid v Rayo Vallecano|
|Robben out until January as Bayern look to avoid serious injury|
|Milan avoid UEFA ban in FFP punishments.|
|Mourinho compares Liverpool to ´an amazing house´ but insists trophies matter|
|Brisbane Roar 2 Melbourne Victory 4: Muscat´s men hit A-League summit|
|Bumrah confident second Test is ´in the balance´ after India recovery|
|Isco gesture was for a corner or foul, claims Solari|
|Harris leads Australia into ascendancy on day one|
|ATP announces candidates to host future Finals|
|Ronaldo: Juventus fans refuse to lose to Torino|
|Hero Rivers feared he had cost Chargers in KC|
|Williams would welcome Llorente back to Athletic Bilbao|
|Liverpool v Manchester United: Minding the gap|
|Milan elimination unjust, fumes Leonardo|