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.
|LeBron scores 51 in Lakers´ win, Warriors fall to Spurs|
|Win more than Djokovic? Let´s chill out – Zverev|
|Steelers´ rally highlights wild day of close, last-minute finishes|
|Modric not worried about Ballon d´Or|
|Saints pull away for blowout victory over Eagles, extend winning streak to nine|
|Martinez laments loss of control by Belgium|
|Logano claims first NASCAR Cup championship|
|Luis Enrique delighted with attitude of Spain´s squad|
|Stevens tells Celtics to get ´tougher´|
|Griezmann: Being Messi´s lieutenant played a part in rejecting Barcelona|
|Curry proud of how Warriors handled Green-Durant incident|
|Courtois: Belgium thought Nations League job was done|
|Howell ends 11-year title drought to deny record-breaking Rodgers|
|Robben dismisses Bayern title talk|
|Huge blow for Redskins as QB Smith breaks tibia and fibula|
|Switzerland 5 Belgium 2: Seferovic treble crowns incredible comeback|
|Titans DC Pees taken to hospital during Colts game|
|Spain 1 Bosnia-Herzegovina 0: Debutant Mendez spares Morata´s blushes|
|Peterson goes sixth on rushing touchdowns list|
|Titans QB Mariota suffers elbow injury|
|Djokovic hails much-improved Zverev|
|Arnautovic refuses to discuss West Ham future after Austria win|
|Redskins QB Smith carted off after gruesome ankle injury|
|Jaguars shut down Jalen Ramsey trade rumours|
|Classy Zverev revels in victory, hails defeated Djokovic|
|Forget the Nations League was ever invented, jokes Northern Ireland boss O´Neill|
|Magnificent Zverev claims ATP Finals title|
|Mahrez double fires Algeria to 2019 AFCON|
|Mbappe hoping for French winner of Ballon d´Or|
|Northern Ireland 1 Austria 2: Last-gasp winner denies hosts maiden Nations League point|
|Teenager admits assaulting Wales great Thomas|
|Browns deny Condoleezza Rice is candidate for head coaching job|
|Koeman: Netherlands not favourites for Germany clash|
|Dalic ´not sad´ but blames fatigue for Croatia relegation|
|Proud Southgate hails England hero Kane as world´s best goalscorer|
|Last-gasp Exeter penalty try shatters Bristol|
|Mbappe dismisses talk of Cavani-Neymar rift|
|Keita will do ´great things´ for Liverpool – Mane|
|Mourinho needs time to fix Manchester United - Veron|
|Southgate sees progress as England reward loyal support|
|Miller hungry to ´knock out a Brit´ after Dinu demolition|
|Yasir, Hasan put Pakistan in control with five-wicket hauls|
|England´s resilience delights Kane as Three Lions secure Nations League Finals spot|
|Kane proves Nations League importance to England in Wembley decider|
|Muller, Hummels still important for Germany, says Low|
|Tevez in line for start in Copa Libertadores final second leg|
|England 2 Croatia 1: Kane able to secure Nations League Finals spot|
|It doesn´t sound real - Molinari stunned by 2018 exploits|
|Wales legend Thomas victim of alleged homophobic attack|
|Marquez crashes again as Dovizioso wins rain-interrupted Valencia GP|
|Warriors owner denies taking sides following Green-Durant spat|
|Alisson can become a global great, says Dida|
|The Sunday Seven - 7 Key Opta facts for NFL Week 11|
|Teen driver ´fine´ after sustaining spinal fracture in F3 crash|
|Willett wins first title since Masters triumph, Molinari tops Race to Dubai standings|
|Southgate overcomes ´stigma´ of being sacked to thrive with England|
|Anthony to Lakers ´not a question for myself´, says LeBron James|
|Warriors´ Stephen Curry staying ´cautious´ with injury recovery|
|Gunter hopes Bale can help family jet in to witness Wales record|
|Root pleased to practice what he preached|
|Tianjin Quanjian threaten action after Modeste returns to Cologne|
|I had to stop Kemba getting 70! – Jimmy Butler reflects on dramatic game-winner|
|Molinari wins Race to Dubai|
|Rooney: Some ex-players can´t come to terms with England doing well|
|In a spin: England´s win against Sri Lanka sets new record|
|Ogier wins sixth straight WRC title|
|Rogic, Kruse to miss Socceroos´ Lebanon friendly|
|Joerger has Kings´ ´full support´, says GM Divac|
|England seal series win over Sri Lanka|
|Butler´s heroics spoil Walker´s 60-point game as 76ers beat Hornets|