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.
|Shaw: Man United showed too much respect to Juve|
|CAF Champions League Review: Al Ahly to face ES Tunis in final|
|76ers star Simmons dealing with back tightness|
|Roma boss Di Francesco hails ´extraordinary´ Dzeko|
|Pizzi and Jardel rue Benfica´s Ajax reverse|
|Championship review: Leaders held at home, Smith suffers first Aston Villa defeat|
|Mourinho suggests Manchester United must spend to rejoin European elite|
|Manchester City reached their peak against Shakhtar - Guardiola|
|I really missed that winning feeling – Kroos|
|Lopetegui believes Real Madrid win can be turning point|
|Allegri: Juventus still making too many mistakes|
|Cole leads unbeaten Avellino to overtime victory|
|Mourinho hails ´amazing´ Chiellini and Bonucci after Juventus outclass United|
|Simeone glad to have Costa back for Dortmund clash|
|Lopetegui to remain in charge for El Clasico - Butragueno|
|Isner saves two match points to beat Norrie, Federer grinds out victory|
|Icardi happy at Inter ahead of Barca return|
|Marcelino satisfied with point after Valencia hold on at Young Boys|
|Hoffenheim 3 Lyon 3: Joelinton rescues a point after Kramaric´s double|
|Ajax 1 Benfica 0: Last-gasp Mazraoui seals dramatic win|
|Roma 3 CSKA Moscow 0: Dzeko turns on the style|
|Kovac lauds dominant Bayern|
|Shakhtar Donetsk 0 Manchester City 3: Silva sparkle to dominant display|
|Manchester United 0 Juventus 1: Dybala downs Mourinho´s men on Ronaldo´s return|
|Real Madrid 2 Viktoria Plzen 1: Benzema and Marcelo´s goals give holders first win in six|
|Lakers´ Rondo denies spitting on Rockets´ Paul|
|Robben and Rafinha want more from Bayern|
|Federer survives Krajinovic scare to maintain Basel run|
|Green accuses NBA of double standards, calls Lakers-Rockets suspensions ´garbage´|
|New York Giants send Apple to Saints|
|Morgan aims to solve Colombo mystery after record ODI defeat|
|AEK Athens 0 Bayern Munich 2: Lewandowski helps to further ease Kovac woes|
|Young Boys 1 Valencia 1: Hoarau penalty denies Marcelino´s men|
|Mourinho walks to Old Trafford as United arrive late again for Champions League|
|Bale and Benzema back for Madrid as Lopetegui rings changes|
|Carr denies ´fractured relationship´ with Raiders team-mates|
|De Bruyne to start for Manchester City against Shakhtar Donetsk|
|France lose Le Roux and Fofana for November Tests|
|Martino to leave Atlanta United amid Mexico links|
|Pochettino cautious over Eriksen return|
|Ancelotti an inspiration for PSG boss Tuchel|
|Persepolis 1 Al Sadd 1 (2-1 agg): Iranians into first AFC Champions League final|
|Wales boss Gatland returns to New Zealand after father´s death|
|Sri Lanka hand England their heaviest ODI defeat|
|Nuggets guard Will Barton undergoes surgery|
|Surprise package Svitolina closes in on semi-final berth|
|Alexander-Arnold targets glory at home and abroad|
|Pogba relishing emotional Juventus reunion|
|Alba hopes Lopetegui keeps Real Madrid job|
|Valverde not expecting Messi magical recovery|
|Wozniacki calms fears over knee injury|
|Maybe it´s my interviews - Klopp on Liverpool´s room for improvement|
|Language no barrier to Dortmund dangermen Reus and Alcacer|
|EPCR confirms no replay of Bath-Toulouse Champions Cup fixture|
|F1 Raceweek: Five the magic number as Hamilton eyes Mexico repeat|
|RFU to introduce in-season breaks for players|
|Nainggolan misses Barcelona trip|
|Wozniacki battles through knee complaint to down Kvitova|
|Alcacer: Two seasons at Barcelona not lost|
|Henderson, Keita to miss Liverpool´s Red Star clash|
|Khabib holds talks over Mayweather Moscow fight|
|Wolf in for Titz as Hamburg try to stop slump|
|Davies released from Wales squad as Evans comes in|
|Mbappe on track to match Messi and Ronaldo, says Giuly|
|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|