The visitors -- playing only their third Test ever -- reduced Bangladesh to 136-6 before rain forced early stumps on the fourth day, with the hosts, who were set a record target of 398 runs, still needing 262.
The highest successful run chase in Bangladesh is 317-7 by New Zealand at the same ground in 2008.
"Yes, we are bit excited because we are in a good position," Afghanistan's wicketkeeper-batsman Afsar Zazai said.
"It means a lot to be honest," he added.
"The people know about us good enough in white-ball cricket. We've discussed in our dressing room that this Test match is very important for us to win because we want to show we can play Test cricket."
Skipper Shakib Al Hasan remained unbeaten on 39 runs, giving a little hope to Bangladesh amid the gloom at the Zahur Ahmed Stadium, where rain interrupted play in all three sessions much to Afghanistan's frustration.
Shakib will resume the fifth day's play along with Soumya Sarkar, the last recognised batsman for Bangladesh, who was yet to open his account.
Shakib seemed to be preparing for a loss.
"The realistic result is we are very close to defeat. Unless there is some rain... probably we are losing," he said.
Rashid, who made his debut as youngest-ever Test captain, led Afghanistan from the front, finishing the day with 3-46 while left-arm chinaman Zahir claimed 2-36 runs.
Retiring all-rounder Mohammad Nabi claimed the other wicket.
Zahir started the victory push when he dismissed opener Liton Das, who was trapped leg before for nine two balls after a caught-behind decision against him was overturned by the TV umpire on review.
One-down Mosaddek Hossain chased a ball from him wide outside the off-stump to give a catch to Asghar Afghan at long off after making 12 runs.
Rashid trapped Mushfiqur Rahim plumb in front after the former Bangladesh skipper started confidently to make 23 off 25 balls.
Rashid delivered another blow in his next over to dismiss Mominul Haque out lbw for three.
Nabi removed Shadman Islam, who made 41 runs, the highest for Bangladesh so far in the second innings.
Rashid then snapped the wicket of Mahmudullah Riyad for seven before rain provided the home side some respite.
Earlier, resuming at 237-8 after more than two hours' delay due to drizzle, Afghanistan added 23 runs to their overnight score before they were all out for 260, which took their lead close to the 400-run mark.
Yamin Ahmadzai was run out for nine and off-spinner Mehidy Hasan removed last man Zahir, leaving Zazai stranded on 48.