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.
22. Januar 2019
|Kvitova getting back to her best, says Barty|
|Kvitova revels in first semi of ´second career´|
|Messi´s the best player in every world – Boateng dismisses past Real Madrid comments|
|Thunder frustrations continue against Renegades|
|Alonso vows to clear name in tax fraud case|
|Classy Nadal downs Tiafoe to set up Tsitsipas semi|
|Hoedt leaves Southampton for Celta Vigo on loan|
|Melbourne City 4 Western Sydney Wanderers 3: Hosts edge thriller with two goals in last six minutes|
|Wilder won´t even pick up the phone - Hearn not hopeful of AJ bout|
|Sala was on board missing plane, say French authorities|
|Arsenal´s Bellerin out for season with ACL rupture|
|Gatland waiting on ´concrete´ offers|
|Ronaldo accepts prison sentence and €18.8m fine for tax fraud|
|Tsitsipas: It was vital to back up Federer win|
|Awesome Kvitova ends Barty´s home run in Melbourne|
|CA rejects Thunder appeal for full points in abandoned Heat clash|
|Emiliano Sala: Concerns grow for Cardiff striker after plane goes missing|
|Harden unimpressed with refs in Rockets´ 76ers disappointment|
|Ronaldo arrives for sentencing in tax fraud case|
|Record-breaking evening ´one of those nights´ for Warriors star Thompson|
|Hazard still interested in Real Madrid but won´t rule out Chelsea stay|
|Collins moves past Pavlyuchenkova, into Australian Open semis|
|Kohli makes history with ICC awards sweep|
|Thompson sets NBA record with 10 straight made three-pointers to open game|
|76ers hand Rockets largest loss of season, Harden scores 37 points|
|Tsitsipas overcomes Bautista Agut to continue Aus Open run|
|Barcelona move a ´dream come true´ for Boateng|
|Rams coach McVay on Gurley: I´ve got to get him more opportunities|
|Butler´s sprained wrist not expected to keep him out ´long term´|
|Saints owner Benson will ´aggressively pursue changes in NFL policies´|
|Levante to take Copa case to CAS|
|It can happen – Allegri plays down Ronaldo penalty miss|
|Mavericks´ Doncic becomes second-youngest player to record triple-double|
|Yankees send Sonny Gray to Reds|
|Ashley Cole reunited with Frank Lampard at Derby County|
|Arnold ready to mix things up in 2019 Asian Cup quarter-finals|
|Arum: Joshua desperately needs to fight in the United States|
21. Januar 2019
|South Korea v Bahrain: Bento optimistic of continuing unblemished campaign|
|Bolton Wanderers 0 West Brom 2: Baggies bounce up to third after tennis ball protest|
|Confident Moeen ready to shine for England in the Caribbean|
|Juventus 3 Chievo 0: Allegri´s men cruise despite Ronaldo penalty save|
|Boateng completes shock Barcelona switch|
|United Arab Emirates 3 Kyrgyzstan 2 (after extra time): Khalil penalty sets up Socceroos showdown|
|West Indies add Drakes to new-look coaching team|
|Barcelona is a huge opportunity – Boateng confirms shock move is close|
|Donnarumma wishes Higuain luck ahead of expected Chelsea switch|
|Qatar v Iraq: Katanec anticipating ´huge challenge´ in last 16|
|Nuno hit with FA misconduct charge for pitch celebration|
|Furious Carreno Busta and Zverev bow out, Djokovic marches on|
|#NotMartinFromWakefield – Siewert shows viral sensation the door|
|Djokovic feeling the strain after late-night Medvedev battle|
|Henderson sidelined again ahead of Six Nations|
|Australia 0 Uzbekistan 0 (aet, 4-2 on penalties): Ryan heroics see holders hobble onwards|
|Halep exit leaves four-way fight to be crowned number one at Australian Open|
|Super Bowl-bound Rams set for London return, Chiefs to face Chargers in Mexico|
|Huddersfield appoint Siewert as Wagner´s replacement|
|Genoa 0 AC Milan 2: Borini and Suso step up with Higuain left out|
|McTominay signs new Manchester United contract|
|Pizzi to stand down after Saudi Arabia elimination|
|Boateng closing in on shock Barcelona switch - reports|
|Catalans to defend Challenge Cup after resolving RFL dispute|
|Djokovic wears down Medvedev to reach last eight|
|Mouratoglou: I knew ´loyal´ Serena would not fire me after US Open turmoil|
|Barcelona B defender Wague accuses Ejea fans of racist abuse|
|I felt like I had been hit by a train - Halep upbeat despite losing Serena battle|
|Arsenal confirm Mislintat departure|
|Icardi will renew, 100 per cent - Wanda Nara offers latest Inter assurance|
|Japan 1 Saudi Arabia 0: Four-time winners send Pizzi´s men out|
|A souvlaki maybe named after him, a growing fan base – Tsitsipas creating Melbourne buzz|
|Barca winger Dembele out for 15 days|