Kieran Powell's second century of the test and Darren Bravo's 76 propelled West Indies to 244-6 and a 215-run lead against Bangladesh on the fourth day of the first test.
Powell and Bravo shared 189 for the second wicket but were among five wickets to fall after tea, as Bangladesh struck back to keep hopes alive of a fourth win in 74 tests.
Shakib Al Hasan, Rubel Hossain and Sohag Gazi shared two wickets each.
Bangladesh was dismissed for 566 - its first time past 500 - just before lunch to earn a rare first-innings lead of 29 runs.
Nasir Hossain missed out on his first test century, falling for 96.
West Indies began its second innings inauspiciously, as Chris Gayle was out caught behind for a quickfire 19 to paceman Rubel Hossain, who struck again in the final session to take out Bravo and start a collapse.
Until then, Powell and Bravo combined well, although Bangladesh blew chances to end that partnership early. Powell, on 17, was dropped twice off successive deliveries by Shadahat Hossain.
Junaid Siddique fumbled the first in the slips, and Hossain dropped the harder second at his ankles.
Powell and Bravo carried West Indies safely past tea, and Powell rushed to his century with a third boundary in the one over off Rubel Hossain. Powell got there off 164 balls, including 12 fours and a six.
With his 117 in the first innings, he became only the ninth West Indian to score two hundreds in the same test, and the first since Brian Lara in 2001.
Two overs later, he lost Bravo, who edged behind a loose shot at a ball wide of the off stump. Bravo's 76 was off 121 balls.
From 209-2, West Indies slumped to 244-6.
In the over after Bravo departed, Marlon Samuels was out for 1 to Gazi, fending off a riser to short leg. Powell was next, misreading a straighter delivery from Shakib and being caught behind by Mushfiqur Rahim.
Powell's 110 came off 197 balls.
Denesh Ramdin was lbw to Shakib for 5, and when Gazi ended Veerasammy Permaul's brief cameo for 10 stumps were pulled.
Rubel Hossain had 2-35, Shakib 2-56, and Gazi 2-63.
Earlier, Nasir scored 96 for Bangladesh and Mahmudullah added 62 to lead the hosts to 566 all out just before lunch after resuming the day at 455-6.
Nasir cleared the rope four times and stroked six boundaries in a 136-ball innings that helped give the hosts a first-innings cushion in reply to the West Indies' 527-4 declared.
He was finally out, tantalisingly short of his maiden test hundred when he chased a slower ball from Tino Best and edged a low catch to Gayle at slip.
The Bangladesh batting order contributed throughout the 10-hour innings, with opener Tamim Iqbal scoring 72, Naeem Islam adding 108 and Shakib out for 89.
Ravi Rampaul led the bowlers by taking 3-118, while Sunil Narine returned 3-148 and skipper Darren Sammy had 2-83.
Who was your pick of the Black Caps bowlers in the first SA ODI?