Yasir Shah spun Pakistan back into the second test when he picked up six wickets to leave West Indies reeling on day four in Barbados on Wednesday.
Shai Hope came within 10 runs of his maiden test century for West Indies but a late collapse left the match on a knife-edge at the close at Kensington Oval in Bridgetown.
West Indies were 264 for nine wickets in their second innings, an overall lead of 183 runs heading into the final day.
Hope, whose test average before this match was a miserable 15, finally justified the faith shown in him by the selectors with a polished performance, mixing fine strokeplay with stout defence.
But with a century seemingly within his grasp, he played a loose shot to leg-spinner Yasir and was caught at cover for 90.
Hope’s departure precipitated a collapse, with Vishaul Singh falling to the next ball, bowled by paceman Mohammad Abbas for 32.
West Indies captain Jason Holder survived the hat-trick, but was dismissed by Yasir in the next over and Yasir claimed two more scalps as West Indies lost six wickets for 26 runs.
Yasir ended the day with figures of 6-90, after last week picking up 6-63 to bowl Pakistan to victory in the first test in Jamaica.
Pakistan lead the three-test series 1-0 and will fancy their chances of clinching it, though West Indies have scored enough to give their bowlers a chance.
(Reporting by Andrew Both, editing by Ed Osmond)