Kraigg Brathwaite and Jason Holder starred with bat and ball respectively on Tuesday to give West Indies a golden opportunity of ending their miserable tour of the United Arab Emirates with a consolation third-Test victory over Pakistan.
The Windies were whitewashed in both limited-overs formats before losing the first two Tests against Misbah-ul-Haq's side.
However, Pakistan face an uphill battle to avoid defeat in Sharjah, after ending day three in trouble on 87-4, leading by just 31.
Brathwaite improved his overnight score of 95 to 142 not out as the Windies posted a total of 337 in their first innings, the 23-year-old facing 318 deliveries and becoming only the fifth West Indian opener to carry his bat.
Pakistan then lost four wickets in quick succession before wiping out their deficit of 56, Holder (3-10 from nine overs) leading by example in a spell of admirable accuracy and hostility.
Things could have been even better for West Indies had Shannon Gabriel not over-stepped when inducing an edge to slip from Sarfraz Ahmed, who duly reached stumps unbeaten on 19 alongside Azhar Ali (45 not out).
Having resumed five shy of three figures, Brathwaite brought up his fifth Test hundred in Tuesday's first over, but saw Holder depart when the skipper was bowled for 16 shouldering arms to Mohammad Amir.
Devendra Bishoo went on to provide fine support to the centurion, a battling ninth-wicket stand of 60 enough to earn West Indies a handy first-innings advantage.
The gritty Brathwaite survived a scare on 121 when an edge off Mohammad Nawaz was dropped by wicketkeeper Sarfraz.
It was not until the afternoon session that Pakistan finally dismissed the tourists, Wahab Riaz (5-88) completing only his second five-wicket haul in Tests by having Bishoo (27) and Gabriel (0) caught behind either side of Alzarri Joseph (6) chipping tamely to cover.
The hosts took tea in an encouraging position on 32 without loss, only to then collapse as Holder hit his stride, claiming three wickets in as many individual overs.
Sami Aslam (17) and Asad Shafiq (0) were both bounced out by the all-rounder, who drew catches from fine-leg and gully respectively, before Younis Khan was strangled down the leg side without scoring.
Pakistan were still eight runs in arrears when captain Misbah threw his wicket away, holing out to deep backward square-leg off Roston Chase.
Azhar and Sarfraz dug in to see out the remainder of the day, although the latter received a let-off on nine when he fended a Gabriel bouncer to slip, only for a no-ball to be called.