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.
Abbas has figures of 3-26 to add to his four wickets in the first innings, but leg-spinner Yasir Shah was still wicketless in the match.
Australians started their chase on day 4 comfortable with another good opening partnership. They have now won two and drawn two of their 16 Tests in Asia since 2012.
Usman Khawaja followed up his first innings score of 85 with a fighting century while debutant Head went back to the hut after scoring 72 runs.
Pakistan failed to get a single wicket in the first session after Australia resumed at 136-3.
At stumps, opener Usman Khawaja was batting on a fighting 50 and Travis Head on 34, as the pair had added an invaluable 49 for the unbroken fourth-wicket stand to prolong the visitors' resistance on a tired and spinning pitch. He was trapped leg-before sweeping Yasir. He hit five fours in his 175-ball knock.
Liverpool vs Man City: three things we learnt
Before the season started I thought United and Liverpool would both be close to City this time. And to match City, Liverpool must be ruthless against "lesser" opponents.
But just after the left-handed Khawaja made the highest score by any visiting batsman in Asia, passing Daniel Vettori's 140 in 2009 in Colombo, he was out.
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.
Australia are now on their first Test series since the ban of their iconic players Steve Smith and David Warner due to the ball-tampering saga.
Hard-working fast bowler Mohammad Abbas took three wickets in seven balls to bring Pakistan closer to victory in the first Test against Australia in Dubai on Wednesday. Australia wobbled but Khawaja and Paine, who batted for 3 hours and 39 minutes, ensured a draw.
Abu Dhabi will host the second and final test starting on Tuesday.
Pakistan opener Imam-ul-Haq will miss the match after he suffered a fractured finger fielding on Thursday.