Wrist spinners wreaked havoc on Day 4 to take Afghanistan closer to a famous win against Bangladesh, who were at 136/6 and still needing 262 to win in the one-off Test in Chattogram on Sunday.
Skipper Rashid Khan took three wickets while Zahir Khan nabbed two as Bangladesh batters were flattened by their guile.
Only skipper Shakib Al Hasan waged a lone battle and remained unbeaten on 39.
Besides him, opener Shadman Islam scored 41.
Resuming at overnight score of 237/8 in 83.4 overs with a lead of 374, Afghanistan set Bangladesh a stiff target of 398 to win after start of play was delayed due to bad light.
Wicketkeeper and overnight batter Afsar Zazai remained unbeaten on 48. For the hosts, skipper Al Hasan returned best figures of 3/58.
Bangladesh sent Liton Das to open the batting instead of Soumya Sarkar but to little effect as Das was out for nine, with Zahir Khan trapping him in front after lunch.
Bangladesh kept losing wickets as Afghanistan skipper Rashid Khan removed Mushtiqur Rahim (23) and Mominul Haque trapped lbw.
Rashid could have had another wicket had he managed to hold on to a sharp return catch off Al Hasan's bat.
On day 3, Afghanistan put themlseves in the driver's seat largely thanks to a 108-run stand between Asghar Afghan and 17-year-old opener Ibrahim Zadran.
Bangladesh started the day on 196/8 and Mohammad Nabi, playing his last Test, took the first wicket of the day off his third ball, bowling Tauijul Islam through the gate. Two overs later, Rashid Khan finished things off by trapping Nayeem Hasan LBW, thus completing his five-wicket haul.
Afghanistan started their second innings with a lead of 137. Bangladesh star Al Hasan however ensured that they didn't get off to a smooth start, taking back to back wickets off his second and third ball in the opening over. He first trapped Ihsanullah before the stumps and then dismissed first innings centurion Rahmat Shah with a catch off his own bowling. Hashmatullah Shahidi was then dismissed on 12 by Nayeem Hasan after which Asghar and Zadran deflated the hosts for a better part of the next 47 overs.
Asghar, who missed out on a ton by just eight runs in the first innings, scored his second fifty of the Test before falling to Taijul Islam. 14 overs later, Ibrahim Zadran fell on 87 off 208 balls as he tried to go for a maximum over long on off Nayeem Hasan. He ended up finding the fielder on the boundary.
That left wicketkeeper Zazai to bat with the tail. He had a 30-run stand with Rashid Khan, who scored a 50 in the first innings, before the latter fell to Taijul. At the stumps, induced by a power failure in the stadium, Afghanistan were 237/8 with Zazai being accompanied by Yamin Ahmadzai.
Brief scores:
Afghanistan 342 & 237/8 (Ibrahim Zadran 87, Asghar Afghan 50; Shakib Al Hasan 3/53)
Bangladesh 205 (Mominul Haque 52, Mosaddek Hossain 48; Rashid Khan 5/55) & 136/6 (Shakib 39 not out; Rashid Khan 3/46)