England put themselves on course for victory in the first Test against Bangladesh on Sunday after building a huge 434-run lead on the third day despite losing five wickets in quick succession.
The tourists ended the day on 131-5 in their second innings after opting to bat again instead of enforcing a follow-on despite having a 303-run first innings lead in Chittagong.
Off-spinner Graeme Swann completed his fifth five-wicket haul in Tests to help England, who had declared their first innings on 599-6, bowl out Bangladesh for 296.
Mahmudullah had England captain Alastair Cook caught by Aftab Ahmed at fine leg boundary for 39 runs. Shakib then dismissed Jonathan Trott, who was smartly caught by Zunaed Siddique at square leg for 14.
Kevin Pietersen, off the mark on his second ball with a four, batted aggressively until Shakib had him lbw for 32 runs. The former captain struck five fours and a six in his 24-ball innings.
Razzak then removed Michael Carberry (34) and Paul Collingwood (three) in successive overs to give the home side something to cheer with in an otherwise lopsided match so far.
Bangladesh, resuming on 154-5 overnight, suffered a big blow in the third over of the morning when Tim Bresnan bowled opener Tamim Iqbal for 86 with a straight delivery.
However, their lower-order offered some resistance with vice captain Mushfiqur Rahim reaching a half-century.
A run out and then two wickets in one over from Swann brought an abrupt end to their innings.
Rahim shared an 113-run partnership with Naeem Islam, an eighth-wicket record for Bangladesh, before the hosts lost their last three wickets in the space of four balls.
Naeem was run out for 38 when left stranded attempting a second run after Rahim steered Tim Bresnan towards point. Carberry chased the ball and threw to wicketkeeper Matt Prior and Naeem had no chance to return.
Substitute fielder James Tredwell took a blinder at short midwicket in the next ball off Swann to dismiss Rahim, who departed on 79, making his fifth test fifty.
Swann, who had earlier dropped a return catch of Naeem on 13, bowled Rubel Hossain two balls later to end the innings and finish with 5-90.
England (first innings): 599-6 dec
Bangladesh (first innings): 296 all out
England (second innings):
A Cook c Aftab b Mahmudullah 39
M Carberry lbw b Razzak 34
J Trott c Zunaed b Shakib 14
K Pietersen lbw b Shakib 32
P Collingwood c Mahmudullah b Razzak 3
I Bell not out 0
M Prior not out 0
Extras: (b-5 lb-2 nb-2) 9
Total: (5 wickets) 131
Fall of wickets: 1-65, 2-87, 3-126, 4-130, 5-131
To bat: S. Broad, T. Bresnan, G. Swann, S. Finn.
Bowling: Shahadat 6-0-19-0, Rubel 5-1-25-0 (nb-2), Mahmudullah 8-0-26-1, Naeem 3-0-14-0, Shakib 10-1-33-2, Razzak 4-2-7-2.