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.
|Raptors fans give former coach Casey standing ovation in return|
|Martinez hails Hazard leadership|
|Muller going through ´difficult´ period, says Low|
|Betances wants Yankees to sign Machado|
|Rays´ Snell, Mets´ deGrom win Cy Young Awards|
|Dinwiddie to debut Stan Lee-inspired shoes against Heat|
|Iberostar Tenerife and Segafredo Virtus Bologna stay perfect in BCL|
|Rooney wanted to finish career at Manchester United|
|Red Sox give manager Cora contract extension through at least 2021|
|WATCH: Ronnie O´Sullivan hits blue with calamitous break-off shot|
|Matuidi: Mbappe has a great personality, like Ronaldo, Messi and Zlatan|
|Cilic beats Isner to hand Djokovic semi-final spot|
|Mendy undergoes knee surgery|
|Warriors´ Curry will not play during three-game road trip|
|Ramos refuses to retaliate after Lovren jibe|
|Qatar pull off shock win over Switzerland|
|Tuilagi could make England return against Australia|
|Rooney has earned England reward - Sarachan|
|Croatia thrashing means nothing now – Luis Enrique|
|Chelsea and Everton among Arnautovic suitors, claims agent|
|TJ Watt hopes to win NFL sacks race with brother JJ|
|Modric defends Ramos after Lovren comments|
|Southgate hails ´outstanding´ Delph as he talks up England strength in depth|
|No war with Manchester United over Fellaini, insists Martinez|
|Rooney to wear number 10 shirt against USA and receive armband from Delph|
|I don´t feel pressure of Liverpool expectations, claims Klopp|
|Steelers´ Roethlisberger texted Bell but ´didn’t hear back´|
|Reus and Kroos to sit out Germany´s clash with Russia|
|Van Dijk happy to recommend De Ligt if Liverpool ask|
|Sauber announce launch of junior programme|
|No ´breathtaking tennis´ in Djokovic´s win against Zverev|
|Curran: England spinners will be key in Kandy|
|Djokovic charges past Zverev to move closer to ATP Finals progression|
|Messi is a football alien - Malcom|
|Sky´s the limit for Sancho, says Dortmund team-mate Pulisic|
|Radwanska retires from tennis at 29|
|Maybe one day - Pulisic open to Premier League move|
|Suso ´proud´ of Real Madrid speculation but happy at AC Milan|
|Betis president convinced Lo Celso will stay|
|Injured Holder out of Bangladesh tour|
|Germany face relegation, final spots up for grabs - Nations League state of play|
|James Rodriguez out for several weeks with knee injury|
|Curran´s brilliant fifty rescues England´s innings|
|Lenglet: No problem with Dembele at Barca|
|Townsend rings the changes for Springboks clash|
|Claudio Ranieri´s managerial career in Opta numbers|
|Mahmudullah´s first century in eight years boosts Bangladesh|
|Fellaini gets the chop ahead of 31st birthday|
|Maradona: Solari will not last at Real Madrid|
|Molinari: Race to Dubai success would not surpass Ryder Cup glory with Fleetwood|
|Dortmund star Sancho was a Bayern target, confirms Salihamidzic|
|Gerrard enjoying ´buzz´ of management|
|Hamilton questions approach to Formula One expansion|
|Ranieri honoured to lead ´exceptional´ Fulham squad|
|Solari saw Isco out of shape - Ceballos|
|Ranieri replaces Jokanovic at Fulham|
|Durant keeps details of Green spat ´in-house´ but envisages resolution|
|Rooney: Kane and Sterling are England superstars|
|Messi will make Argentina return, says Maradona|
|Warriors drop Hawks as Green serves suspension|
|In-form Healy sends Australia into semis|
|Former NBA star McGrady says Carmelo Anthony should retire|
|Celtics´ Smart: We have to look at ourselves in the mirror|
|Federer plays down preferential treatment talk|
|Mourinho is better than Guardiola – Maradona|
|Mbappe plays down Pele comparisons|
|Don´t worry bro – Mendy responds to Trump|
|Melvin, Snitker win manager of the year awards|
|Warriors´ Green suspended for Hawks clash|
|Asensio: It´s not for me to lead Madrid|