Set a target of 286 to win the Test match, Bangladesh reached 253 for 8 at stumps on the fourth day but face the tough task of securing another 33 runs on a crumbling fifth-day wicket for their first-ever victory over England.
But Stokes trapped Taijul in front and England captain Alastair Cook successfully reviewed the umpire's not out decision to end the dogged ninth wicket stand of 25.
Broad opened the bowling after a fine spell on Sunday night that yielded two for 14 from nine overs and he almost had a third wicket when Rahman's inside edge narrowly avoided his stumps.
Just when Bangladesh were dreaming of an historic victory over England in the First Test, Broad removed Mehedi Hasan, who was nailed lbw, and Kamrul Islam, snaffled at short leg.
Relive the action with Sportsmail's JAMES DUTTON with updates from LAWRENCE BOOTH in Chittagong.
Although Gareth Batty, Moeen Ali and Adil Rashid all chipped in with wickets, England will be concerned at the lack of threat from their trio of spinners.
Overall if we look at the first Test, it was an entertaining game, where Stokes all-round skills played an important role in helping England win the match.
Shakib trapped Joe Root lbw for one in the next over to take his 150th Test wicket before he had Ben Duckett caught by Mominul Haque at forward short leg for 15.
Imrul Kayes departs as Bangladesh lose two wickets at LUNCH! But the positive mindset reaped its own dividends, with Cook forced to shed a few close catchers to patrol his boundaries, and it was a minor victory when England turned to seam as early as the 15th over, when Chris Woakes was thrown the ball in a bid to change the tempo.
The tourists were floundering on 62 for five and a lead of only 107 as Bangladesh's spinners ran through the top order but Stokes kept his cool in stifling heat and on a pitch that is still offering vast amounts of turn.
Gary Ballance fell to Taijul Islam for nine after the break before Shakib grabbed his third wicket by dismissing Moeen Ali for 14.
"It was a really good Test match, to think we were here on day five with that wicket", Cook said after the game.
"We started off pretty well but we have a long way to go from here", said Stokes.
Just when Shakib Al Hasan appeared to take the side to safety, offspinner Moeen Ali again struck with a delivery that shaped in to take the inside edge of Shakib for 24.