Babar Azam fell one short of a maiden Test century after a farcical Azhar Ali run out as Pakistan put themselves well on course for victory over Australia in Abu Dhabi on day three.
Azhar threw his wicket away comically for 64 at Sheikh Zayed Stadium, Mitchell Starc zipping in a throw and Paine whipping off the bails as the number three casually chatted to Asad Shafiq out of his ground thinking he had struck a boundary.
There was also agony for Babar when he was dismissed for 99, but Pakistan should have the last laugh after declaring on 400-9 to set the tourists a highly unlikely 538 to win.
Usman Khawaja's magnificent century denied Pakistan in the first Test, but he was unable to open due to a knee injury on Thursday and his replacement, Shaun Marsh, fell cheaply as Australia were reduced to 47-1 at stumps.
Sarfraz Ahmed (81) earlier made a second half-century of the match, with Nathan Lyon taking 4-135 on a gruelling day for Australia.
Lyon struck in the sixth over of the day with a flighted delivery which deceived an advancing Haris Sohail, who was stumped by Paine.
Azhar followed in bizarre fashion soon after to leave Pakistan 160-4, but Babar and Shafiq capitalised on an excellent batting surface in a stand of 75.
Shafiq was twice dropped by Marnus Labuschagne at short leg off Lyon before the all-rounder dismissed him for 44 in the afternoon session.
Babar had brought up his half-century and continued to tick along effortlessly, launching Labuschagne for six over long-off before Sarfraz did the same to Lyon straight after sweeping him to the boundary.
Peter Siddle rattled Sarfraz on the helmet, but the skipper brought up his second half-century of the match and Babar was on the brink of a first Test hundred when he was trapped leg before by Mitchell Marsh.
Babar reviewed, in hope more than expectation, but was sent on his way after hitting three sixes and another six boundaries in an excellent knock, putting on 133 for the sixth wicket with Sarfraz.
Bilal Asif smashed Labuschagne's first ball after tea for a straight six, but he and fellow spinner Yasir Shah fell in the same Lyon over, much to the frustration of Sarfraz.
Sarfraz decided it was time to deal in boundaries, but missed out on a hundred again when Labuschagne snared him leg before and declared soon after trudging off.
Stand-in opener Shaun Marsh failed for the fourth time in the series, bowled by a peach of a delivery from Mir Hamza which nipped away and struck the top of off stump.
Aaron Finch and Travis Head prevented any further damage from being done, but Pakistan have two days to take the nine wickets needed to win the series.
|Warriors score NBA record 51 points in first quarter against Nuggets|
|Panthers owner Tepper doesn´t rule out Newton missing 2019 because of shoulder injury|
|De Ligt will be world´s best centre-back – Koeman|
|Ronaldo a ´perfect machine´, says Gattuso|
|Barcelona? I can´t say anything - Stuani|
|Silva upbeat about Man City title chances|
|Celtics youngsters say Irving´s callout ´came from a good place´|
|NFL playoffs: Patrick Mahomes v Tom Brady|
|NFL playoffs: Jared Goff v Drew Brees|
|Sixers sign Brewer to 10-day contract|
|Lozano and Morgan scoop CONCACAF awards|
|Lakers ´optimistic´ about LeBron injury|
|Giants produce mammoth fourth quarter against Nymburk|
|Austin FC to join MLS in 2021|
|Henry, Vieira look forward to reunion when Monaco host Nice|
|Barcelona reject Neymar phone call reports|
|Wentz is the quarterback ´going forward´, says Eagles coach Pederson|
|Gattuso: Higuain has not asked to leave|
|Drew Brees by the Opta numbers: 10 facts for QB´s milestone birthday|
|Harry Kane injury: England captain´s history of ankle woe|
|Harry Kane injury: Opta numbers suggest Spurs struggles|
|Harry Kane injury: Tottenham´s options in striker´s absence|
|Allegri: Supercoppa clash practice for Champions League knockouts|
|First in clean sheets, second to Schmeichel in titles – Cech´s Premier League career in Opta numbers|
|Warrington sign England star Widdop|
|Gatland confident Wales can win Six Nations|
|Fulham sign Netherlands international Babel|
|Harry Kane injury: Games the Tottenham striker will miss|
|Simeone focused on matches, not transfer dealings|
|Iran v Iraq: Pressure off for Queiroz & Katanec|
|Vietnam v Yemen: Kocian keeps the faith|
|Darren Bravo back in West Indies Test side for first time since 2016|
|Kane out until March with ankle injury|
|South Korea v China: Son arrives for Group C dead rubber|
|Kyrgyzstan v Philippines: Eriksson remains hopeful|
|McGrath to miss Six Nations, Sexton nearing fitness|
|Kohli savours Dhoni ´classic´|
|Ford: People obsess over Farrell fly-half battle|
|EFL asks Leeds to explain ´spygate´ scandal|
|No alarms for Djokovic and Zverev, Raonic masters Kyrgios|
|Australia 3 Syria 2: Rogic breaks hearts with stoppage-time winner|
|Palestine 0 Jordan 0: Socceroos winner keeps hopes alive for Lions of Canaan|
|Halep: The results don´t matter any more|
|Hard work for Halep as Serena and Osaka sail through|
|Napoli director to take legal action over ´false´ quotes about Rog move|
|Alexander-Arnold facing absence of up to four weeks|
|Solari: We only have one number nine at Real Madrid|
|Halfpenny & Young named in Wales´ Six Nations squad|
|Crawford v Khan confirmed for April 20|
|Centurion Kohli inspires India to level ODI series|
|Wagner hails Huddersfield togetherness after exit|
|Hughes to join Bristol, Le Roux also leaving Wasps|
|ICC appoints Sawhney as new CEO|
|Forest appoint club legend O´Neill as new manager|
|Halep digs deep to gain revenge over Kanepi|
|Cech to retire at the end of the season|
|Brisbane Roar 0 Melbourne Victory 5: Barbarouses treble sinks Roar|
|´Struggling´ Azarenka breaks down in tears following Australian Open exit|
|Dominant Djokovic coasts through in Melbourne|
|Allardyce admits Huddersfield appointment is ´highly unlikley´|
|Choupo-Mouting: Manchester United have changed|
|Faletau set to miss Six Nations with another broken arm|
|UEFA opens disciplinary proceedings into Chelsea chants|
|Serena´s the greatest ever - Bouchard relishing second-round clash|
|Mbappe can become the new Pele - Pele|
|Wade needs to learn quickly if he´s to make NFL switch a success, says Sanu|
|Azarenka beaten in first Australian Open match since 2016|
|Kings use balanced scoring attack to top Trail Blazers|
|Hewitt laughs off Tomic criticism|
|We love Ederson the way he is - Guardiola on Man City´s sweeper keeper|