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.
|Bryant explains how Lakers could beat Warriors|
|Finals hopefuls Isner, Fognini into Stockholm semis|
|Browns trade running back Hyde to Jaguars|
|Mourinho: I´d love to have Hazard at Manchester United|
|Hamilton´s title chances enhanced by Vettel´s grid penalty|
|Deja vu for Enisei as La Rochelle inflict another thrashing|
|Five-star Jovic makes Bundesliga history|
|Liverpool´s scoring slump no concern for cautious Klopp|
|He´s the Special One - Sarri insists he is not on Mourinho´s level yet|
|Second-half blitz guides Leicester to European success|
|Sheffield Wednesday 1 Middlesbrough 2: Besic, Assombalonga see off Owls|
|Goerges rallies to reach Luxembourg Open final, Jabeur makes history|
|Howe: Transfer speculation will not disrupt Ake|
|´Do we really want opera every night?´ - Klopp not changing Nations League view|
|Vile and abhorrent – Chelsea´s Carney responds to online abuse|
|Giants WR Beckham Jr. explains why he might cramp up: ´I really don´t like water´|
|Man City pay training-pitch tribute to Joe Hart|
|Neymar to be rested as Tuchel rubbishes Ballon d´Or concerns|
|Sarri ´not interested´ in Christensen father´s quit threat|
|Cardinals fire offensive coordinator McCoy after 1-6 start|
|Neymar return unlikely, but anything can happen – Valverde|
|Bairstow a doubt for fourth ODI|
|Manchester United fined for late arrival and delayed kick-off against Valencia|
|Australia-Pakistan chat not ´especially polite´ - Sarfraz|
|Pogba relishing ´pressure game´ against in-form Hazard|
|Don´t bet on Cardiff survival, warns Warnock|
|Buffon enjoying Tuchel´s methods at PSG|
|RIP to Wimbledon epics! Isner feels like The Undertaker following final-set tie-break rule|
|Sevilla performance sealed Bernat´s Bayern exit - Hoeness|
|Keita set to miss out as Liverpool monitor injured stars|
|He didn´t want to be here – Guardiola doubts Sancho will return to Manchester City|
|Sarri: Manchester United are the best in the Premier League|
|Mourinho salutes ´brave´ Shaw for ´best possible´ response to criticism|
|No Ballon d´Or distractions for Griezmann, insists Simeone|
|Wigan stand by Hardaker as full-back prepares to undergo rehabilitation|
|Barcelona deny Neymar talk|
|Hazard can win the Ballon d´Or as a Chelsea player, insists Sarri|
|De Bruyne in contention to start in Manchester City´s clash with Burnley|
|Neymar needs to mature to reach Messi levels - Xavi|
|We have a hell of a lot to do - Paine slams Australia batting|
|Kerber and Osaka to meet at WTA Finals|
|Lorenzo out of Japanese MotoGP|
|Real Madrid handed Africa trip in Copa del Rey|
|Allegri: Ronaldo has sharpened Juventus focus|
|No Wade in Wasps squad amid NFL reports|
|Rooney: Five of us controlled Man United dressing room|
|Bayern bosses launch scathing attack on ´disrespectful´ media|
|Saints lock in Lawes to new deal|
|Adelaide United 1 Sydney 1: Debutant Le Fondre rescues a point|
|Madrid can´t look back, only forward - Lopetegui confident of revival|
|Wimbledon to introduce final-set tie-breaks|
|Abbas inspires Pakistan to series victory|
|Madrid boss Lopetegui hopeful on Bale availability|
|Mood is positive at Bayern, insists under-pressure Kovac|
|LeBron offers food for thought after losing Lakers debut|
|Bolt future not an immediate concern for Mariners|
|Hazard: I could finish my career at Chelsea|
|Buffon hoping to avoid Champions League final against Juventus|
|Wilshere not ready for West Ham return|
|Chelsea v Manchester United: Hazard better under Sarri than he ever was with Mourinho|
|The big Friday Premier League quiz|
|Khawaja suffers meniscal tear, doubt for India series|
|Babbel: Klopp must win trophies now at Liverpool|
|LeBron makes spectacular start on Lakers debut, but LA fall to Trail Blazers|
|Broncos thrash Cardinals to end losing streak|
|Price leads Red Sox past Astros and into World Series|
|LeBron makes fast start on Lakers debut with two massive dunks|
|Real Salt Lake 4 New England Revolution 1: Hosts boost play-off chances|
|Simmons gets triple-double in win over Bulls|
|´Ambitious´ Maguire wants Champions League football|