Ben Stokes grabbed two wickets in three balls to deny Bangladesh an historic first victory over England on day five of the first Test, at Chittagong.
The all-rounder capped a stellar match by winning lbw shouts against Taijul Islam and Shafiul Islam in the fourth over of the morning to secure a 22-run win for the tourists, who take a 1-0 lead in the two-game series - Bangladesh all out for 263 in 81.3 overs, Sabbir Rahman unbeaten on 64.
England's margin of victory was the narrowest over Bangladesh in their Test history, easily eclipsing the 77-run success enjoyed by West Indies at Mirpur in 2012.
Ben Stokes celebrates England's victory with Joe Root and Stuart Broad
Bangladesh, set 286 for victory, began the fifth and final day on 253-8 needing just 33 runs to inflict a major blow on the tourists at the start of their seven-Test tour of the subcontinent.
Taijul Islam (16) notched the first boundary of the morning three balls into the second over, gloving an attempted hook off Stokes over Jonny Bairstow to the delight of the few raucous home fans in the stadium.
Cook declined to take the new ball straight away - Taijul whipping Broad for a single off the final ball of the 81st over - and the decision proved justified.
Ben Stokes celebrates England's victory with Joe Root and Stuart Broad
Debutant Sabbir, dropped by Bairstow on 34 on day four, had only a watching brief as England successfully reviewed a 'not out' lbw decision against Taijul, who was hit in front as he stepped across looking to work Stokes (2-20) to leg.
Two deliveries later England's victory was complete as last man Shafiul offered no shot to a Stokes in-ducker that was given out - the home review failing as the ball arrowed in on off-stump and the decision sticking with the umpire.
Consequently, Bangladesh were denied just their eighth victory in 94 Tests and first over England in nine attempts.
Stokes duly took the man-of-the-match award, having bagged 4-26 in Bangladesh's first innings after striking a precious 85.