Chasing a daunting 479, the hosts finished on 346 for eight after batting for 142 overs, with Sediqullah Atal's marathon century leading their resistance.
Bangladesh had dominated large stretches of the match and appeared well placed to push for victory after declaring their second innings at 372 for seven.
However, Afghanistan's batters showed tremendous patience on a largely unresponsive pitch to deny the visitors a win.
Atal was the cornerstone of Afghanistan's resistance, scoring 111 off 332 deliveries in an innings that lasted more than eight hours. He struck nine fours and three sixes, frustrating Bangladesh's bowlers with his determination to bat time.
Qais Ahmad remained unbeaten on 49 off 80 balls, including six fours and three sixes, while Hashmatullah Shahidi contributed 36.
The pair helped Afghanistan navigate the closing stages after Bangladesh had made further inroads into the batting line-up.
Mehidy Hasan Miraz was Bangladesh's most successful bowler in the second innings, taking three wickets for 73 runs from 33 overs. Ebadot Hossain also claimed three wickets, while Taijul Islam and Hasan Mahmud took one apiece.
Bangladesh had several opportunities to put Afghanistan under greater pressure but could not turn their advantage into a victory.
Despite taking wickets at regular intervals, they were unable to break through the home side's stubborn resistance consistently enough.
The visitors' inability to extract significant turn from the surface also complicated their task. With the pitch offering limited assistance to the spinners, Afghanistan's batters were able to settle in and focus on survival rather than chasing the target.
Atal's lengthy stay at the crease proved particularly costly for Bangladesh, who needed to dismiss Afghanistan before the hosts could bat out the remaining time.
His partnership with the lower order ensured that the required run rate never became a factor in the visitors' favour.
Bangladesh had started the final day with Afghanistan on 132 for three, needing another 347 runs for victory. The visitors still had seven wickets to take, but Afghanistan's resistance gradually extinguished their hopes of a result.
Bangladesh's strong position had been built on a solid first innings and a commanding second-innings total.
After being dismissed for 346 in their first innings, Bangladesh restricted Afghanistan to 240 to secure a 106-run lead. Hasan Mahmud claimed five wickets, while Ebadot Hossain took four.
In the second innings, Litton Das struck a brilliant 102 off 117 balls, hitting 14 fours, to anchor Bangladesh's declaration at 372 for seven. Najmul Hossain Shanto scored 82, while Mushfiqur Rahim made 81 and Mehidy remained unbeaten on 52.
Litton became the first wicketkeeper in Test history to score fifty-plus runs in both innings and register nine dismissals in the same match.
The substantial target of 479 gave Bangladesh a realistic opportunity to push for victory, but their bowlers could not finish the job against an Afghanistan side determined to save the match.