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.
|Andy Cole joins Sol Campbell´s coaching staff at Macclesfield|
|Atleti confirm Saul has thigh injury|
|Wood replaces injured Stone in England squad|
|Lebanon 4 North Korea 1: Disciplinary record cruelly denies Radulovic´s men|
|Saudi Arabia 0 Qatar 2: In-form Ali bags brace as Qatar top group|
|Robertson signs new Liverpool deal|
|Vunipola backs Farrell to thrive in solo leadership role|
|People don´t know what´s going on behind the scenes - Mourinho defends United stint|
|Indefatigable Muguruza knocks out Konta at 3:12am|
|Serena coasts, difficulties for Halep and Muguruza´s marathon|
|Lowry retains Abu Dhabi lead|
|Djokovic battles past Tsonga, young guns flourish|
|Louisville airport to be renamed in Muhammad Ali´s honour|
|Emery not thinking about Ozil speculation|
|Sri Lanka hopeful over Kusal Mendis finger injury|
|Oman 3 Turkmenistan 1: Last-gasp Al-Musallami guarantees progression|
|Emery wants Cech to end career ´in a good moment´|
|Japan 2 Uzbekistan 1: Shiotani stunner seals comeback and top spot|
|Calhanoglu deal ´financially impossible´ for Leipzig|
|Not seen at Aus Open since Nadal, Djokovic and Murray in 2009 – ´Next Gen´ make move|
|Martial: Solskjaer lets me express myself|
|Djokovic sees off Tsonga to reach third round|
|Returning Cousins calls Warriors ´the most hated team in sports´|
|Halep injury ´nothing dangerous´|
|Warner picks up elbow injury in Bangladesh|
|Mkhitaryan returning to Arsenal training next week|
|Leeds United pounce for Real Madrid goalkeeper Casilla|
|Watson lights up Gabba before power cut forces abandonment|
|Superb Serena blows Bouchard away|
|Tevez, Hulk, Oscar, Lavezzi - how the CSL stars Dembele is following to China fared|
|Thiem retires from Australian Open|
|Osaka ´not telling´ when it comes to injury niggle|
|Fabinho enjoying Klopp´s management style|
|Halep battles past Kenin in Melbourne|
|Hartley to miss England´s Six Nations opener|
|Dembele departs Spurs for Guangzhou R&F|
|Nacho convinced Isco remains important to Real Madrid|
|Warriors star Curry sets NBA record|
|Raonic survives four-hour marathon against Wawrinka|
|Osaka powers through to Aus Open third round|
|Irving dominates in Celtics´ win over Raptors|
|Irving called LeBron this week to apologise|
|Ajax star De Jong wants to resolve future ´quickly´|
|Payton on Rams CB Peters: I have great respect for him|
|Rockets star Harden matches Chamberlain with historic performances|
|Nishikori survives Karlovic test in Melbourne|
|Vieira reunion felt really weird - Henry|
|´#BetAgainstUs´ - Edelman and Pats embracing underdog status|
|Van der Vaart: Isco the best player in the world|
|I haven´t seen Guardiola or Klopp do that – Lampard unhappy with Bielsa|
|Real Madrid always play to win, insists Casemiro|
|Royals pitcher Skoglund suspended for 80 games after testing positive for PEDs|
|Ronaldo and Juve celebrate Supercoppa Italiana title with Mayweather|
|We are not going to talk about Morata - Simeone reluctant to discuss striker|
|Madrid weak in Leganes loss, says Solari|
|Bologna and Banvit seal Champions League play-off spots|
|LeBron James to miss Thunder & Rockets games but nearing practice return|
|Leganes 1 Real Madrid 0 (1-3 agg): Isco starts as Solari´s side go through despite defeat|
|NFL playoffs 2019: X-factor for each NFC team|
|Mahomes: Chiefs must not repeat mistakes against Patriots|
|Higuain´s Supercoppa benching due to virus, says Milan boss Gattuso|
|Brown fires back at Arians over ´diva´ comments|
|Stone heading home from West Indies tour with back injury|
|Shazier will continue rehab with intention of playing again|
|That´s why we signed him! Allegri hails Supercoppa match-winner Ronaldo|
|Monaco on worst home run in club´s history after Nice draw|
|Atletico Madrid 3 Girona 3 (4-4 agg): Simeone´s side out on away goals|
|Gregg Williams is Jets´ new defensive coordinator|
|Ronaldo: Supercoppa triumph just the start for Juve|
|Monaco confirm Batshuayi talks|