Kieran Powell notched up his second century of the match before Bangladesh brought alive the first cricket test by grabbing five West Indian wickets in 13.1 overs on Friday to raise the spectre of an unlikely victory.
The visitors will take a 215-run lead into the final day but will struggle to add to their tally as the only recognised batsman remaining, Shivnarine Chanderpaul, is unwell and may not be able to bat.
West Indies reached 244-6 at the close on the fourth day and the hosts will fancy their chances of notching up their first test win against a top side having scored their highest ever total of 556 in the first innings.
Powell became the ninth Caribbean batsman to score two centuries in a single test after getting a patient 110 from 197 balls, adding to the 117 he amassed in the first innings.
He shared a 189-run second-wicket stand with Darren Bravo, mainly thanks to the butter fingers of Zunaed Siddique who dropped the batsman on 17 at slip.
"I am not too sure how often it happened but I am happy that it happened to me," Powell said.
Bangladesh got an early breakthrough when Rubel Hossain had Gayle caught behind for 19, but Powell and Bravo denied them any chance of gaining an upper hand with their prolific stand.
Rubel dismissed Bravo for 76 before off-spinner Sohag Gazi forced Marlon Samuels (1) to loft a catch to Shahriar Nafees at forward short leg to trigger a late West Indian collapse.
Left-arm spinner Shakib Al-Hasan induced an edge from Powell to end his knock, which included 12 fours and a six, and trapped first innings centurion Denesh Ramdin for five.
West Indies sent Veerasammy Permaul in ahead of Shivnarine Chanderpaul, who fell ill after smashing a double century in the first innings, and the debutant struck two fours in the first two balls he faced to ease some pressure.
However, Gazi bowled him for 10 on the final ball of the day to cap in a remarkable session for Bangladesh.
Earlier, Bangladesh's Nasir Hossain missed out on his maiden test century when he was out for 96, caught by Gayle at slip off Tino Best.
"A century is a matter of luck. As it was not in my fate I couldn't do it," said Nasir.
Nasir resumed on 33 and added 121 runs for the seventh wicket with fellow overnight batsman Mahmudullah, who made 62.
The duo helped Bangladesh to overhaul their previous highest test total of 488 against Zimbabwe at Chittagong.
Following Mahmudullah's dismissal with the total on 489, Nasir kept his focus and nudged a single to take Bangladesh over the 500-run mark for the first time.
Bangladesh then snatched an unlikely 29-run first-innings lead courtesy of Nasir's 61-run ninth wicket stand with Shahadat Hossain, the last man out as Sunil Narine bowled him for his third wicket of the day.