Usman Khawaja hit a fighting hundred to foil Pakistan and help Australia escape with a draw in the first Test in Dubai on Thursday.
The left-hander hit a solid 141 for his seventh Test hundred, while skipper Tim Paine (61*) and Travis Head (72) also hit half centuries as Australia finished at 362-8 late in the day with lights coming on at Dubai stadium.
After Khawaja was dismissed with 14.3 overs left and Yasir Shah quickly removed Mitchell Starc (1) and Peter Siddle (0), Paine and number ten Nathan Lyon (5*) survived 12.1 overs.
Both had some anxious moments before players shook hands with one ball to go in leg-spinner Yasir's final over.
Yasir had shaken the Australian innings with 4-114 but Australia clung on. They have now won two and drawn two of their 16 Tests in Asia since 2012.
Pakistan captain Sarfraz Ahmed was full of praise for Khawaja.
"We hoped to roll them out but we have to give credit to Khawaja," said Sarfraz.
"We had an idea that he would understand our tactics but it wasn't easy to bat and despite that he soldiered on, we must give him credit."
Paine admitted it was hard work to save the Test.
"It was an extremely tough Test match," said Paine, after his second Test as captain.
"Pakistan played very well but I am proud of our comeback. There was a bit of a collapse but the guys have been working hard over the last few months and I'm happy everything's gone to plan."
Australia's hero was Khawaja, who started the day on 50 not out as Australia resumed on 136-3.
Khawaja and Head added 79 before lunch as Pakistan failed to take a wicket in the first session. The pair eventually put on an invaluable 132 runs for the fourth wicket.
Khawaja, who was born in Pakistan but moved to Australia as a child, batted for eight hours 44 minutes and faced 302 balls before he was sixth man out in the final session. He was trapped leg-before sweeping Yasir.
Khawaja, who hit 11 boundaries, had a top score of 26 in five previous Tests in Asia.
His innings was the second longest in the fourth innings of a Test, behind England's Michael Atherton's 645 minute vigil in scoring 185 not out against South Africa in Johannesburg in 1995. It was the highest fourth-innings score by any visiting batsman in Asia, beating New Zealand's Daniel Vettori's 140 made at Colombo against Sri Lanka nine years ago.
Pakistan started the day needing seven wickets to win but nothing worked for Sarfraz, despite multiple bowling changes.
Pakistan could have had Head leg-before off leg-spinner Yasir on 44, but Sarfraz did not review umpire Richard Kettleborough's not out decision. Replays showed the ball was hitting the stumps.
Pakistan were only rewarded when they took the second new ball as soon as it was due and Hafeez trapped Head leg-before with the first ball. Australia wobbled but Khawaja and Paine, who batted for 3 hours and 39 minutes, ensured a draw.
The second Test starts in Abu Dhabi from October 16.
Pakistan opener Imam-ul-Haq will miss the match after he suffered a fractured finger fielding on Thursday.