Ibrahim Zadran and Asghar Afghan hit half-centuries while Rashid Khan played a quick cameo after claiming five wickets in an innings, as Afghanistan took command in the one-off Test against Bangladesh in Chittagong on Saturday.
The visitors -- playing only their third Test in history -- reached 237-8 at stumps on the third day, setting a huge target for Bangladesh by taking an overall lead of 374 runs.
Debutant Zadran hit highest 87 off 208 balls for Afghanistan in the second innings while former skipper Afghan made 50 off 108 balls, his second fifty, adding to Bangladesh's frustration.
Rashid added 24 off 22 balls before wicketkeeper-batsman Afsar Zazai's unbeaten 34 runs extended Afghanistan's lead.
Skipper Shakib Al Hasan took three wickets for Bangladesh, including two in the first over of the innings, but Zadran and Afghan shared 108 runs for the fourth wicket to snatch the momentum back for Afghanistan.
Shakib trapped Ihsanullah Janat for four in the third ball of the innings and then dismissed first innings centurion Rahmat Shah for a golden duck in the next ball.
Afghan, who also made 92 runs in the first innings, joined Zadran after off-spinner Nayeem Hasan removed Hashmatullah Shahidi for 12.
Taijul Islam dismissed Afghan, who hit four fours and two sixes in his second fifty of the game, before Nayeem ended Zadran's brilliant innings featuring six fours and four sixes.
The spinner also dismissed Mohammad Nabi in the next ball after the all-rounder hit him for a six to revive some hope for Bangladesh.
Rashid then took the attack on Nayeem, hitting him for five boundaries in one over before Taijul bowled him finally.
The Afghan skipper earlier completed his five-wicket to finish with 5-55 as Afghanistan bowled out Bangladesh for 205 runs in the first innings after the hosts resumed the third day's play with 194-8.
Rashid, who scored 51 runs with the bat making his debut as youngest-ever Test captain, took the final wicket of Nayeem to wrap up Bangladesh's innings after Nabi gave a breakthrough in the first over of the day.
Nabi bowled Taijul without allowing him to add any run to his overnight 14 before finishing with 3-56 runs.
Mosaddek Hossain was unbeaten on 48.