Mushfiqur Rahim (83 off 87 balls) and Shakib (51 off 69) showed their class on a difficult surface to help Bangladesh post a competitive 262 for seven after Afghanistan opted to field at the Hampshire Bowl.
Shakib, who also became the tournament's leading run getter on way to his half-century, was also exceptional with the ball. The left-arm spinner ended with figures of five for 29 for in 10 overs, his best in ODI cricket.
With this incredible effort, Shakib also became only the second cricketer after India's Yuvraj Singh to score a fifty and take a five-wicket haul in a World Cup match.
Chasing 263 was always going to be tough for a fragile Afghanistan batting line-up but 48 for no loss in 10 overs raised hopes that the Gulbadin Naib-led side might just get its first win of the tournament after six losses in a row.
However, the batting fell apart after Shakib removed Rahmat Shah (24) and from 49 for no loss, Afghanistan were reeling at 132 for six. The seventh wicket stand for 56 runs between Samiullah Shinwari (49 not out) and Najibullah Zadran (23) saved them the blushes. Afghanistan were eventually all out for 200 in 47 overs.
Bangladesh's third win in seven games took them to seven points and if they win their remaining fixtures against India and Pakistan, the Mashrafe Mortaza-led unit will end the league stage with 11 points.
Earlier, Rahim and Shakib shared a 61-run partnership laying the foundation for a decent score on a slow surface. The India-Afghanistan game here on Saturday also saw batsmen struggle to score freely.
Mosaddek Hossain (35 off 24) provided the much-needed fireworks in the death overs, taking the total past 250. The stand-out bowler for Afghanistan was spinner Mujeeb Ur-Rahman (3/39), troubling the batsmen with his variations.
Liton Das (16) was promoted to open the innings alongside Tamim Iqbal (36) with Soumya Sarkar pushed down the order. Das could not make the opportunity count and was caught at cover off Mujeeb.
Iqbal and star all-rounder Shakib then shared a 59-run stand before Mohammad Nabi hit the former's stumps, leaving Bangladesh at 82 for two in 17 overs.
Shakib, who surpassed David Warner to become the tournament's leading run-getter, played a gritty knock that included just one four.
The world's premier all-rounder has so far scored two hundreds and three half-centuries in the competition.
Rahim, who too has been in sublime form like Shakib, played another valuable knock for his team. Had he not fired, Bangladesh would have struggled to go beyond 225. His innings comprised four boundaries and a six.