The all-rounder took five for 23 to rip through the Bangladesh line-up as they were bowled out for 91 after electing to bat at the Sher-e-Bangla stadium, with seven batsmen failing to reach double figures.
Pakistan lost five wickets chasing the modest target which they eventually overhauled, in the 26th over, to put the tourists up in the three-match series.
Rubel Hossain and Shakib Al Hasan claimed two wickets apiece to leave Pakistan struggling at 63 for five before Afridi top scored with an unbeaten 24 off 23 balls. As the runs dried up on the turning wicket, Afridi broke free with three successive fours off Al Hasan and then cut the same bowler for another boundary to win the game.
Misbah-ul-Haq, the captain, made 16 not out, sharing a match-winning stand of 30 with Afridi.
"It was really looking tough at one stage, the spinners were getting some help, well played by Shahid Afridi," Misbah said.
"One important thing is, when you have a start you have to carry on, that is a problem with us, many of our batsmen get starts and don't carry on."
It was Pakistan's 26th win in 27 one-dayers against Bangladesh, the lone defeat having come during the 1999 World Cup in England.
Bangladesh, who lost half the side for 31 runs on the slow wicket, were dismissed in 30.3 overs and barely managed to surpass their lowest one-day total against Pakistan of 87.
Sarfraz Ahmed, the wicketkeeper, picked up four catches as the four Pakistani spinners shared eight of the 10 wickets.
The second one-dayer will be played at the same venue Friday.
Elsewhere, Tim Bresnan, the England bowler, is expected to be fit for the Test series against Pakistan in the UAE in the new year, despite undergoing surgery on his elbow.
The pace bowler felt discomfort during the recent tour of India and was sent for an operation to remove a bone fragment.
The England and Wales Cricket Board, who announced the news, believe he will be ready for next month's visit to the UAE, who are once again hosting Pakistan due to ongoing security concerns in their country.
England are expected to name their Test squad for the three-match series next week.
Cricket Australia doctor Trefor James said the 30-year-old Johnson underwent surgery in Melbourne on Thursday for a "severe injury to ligaments, commonly referred to as 'turf toe' sustained when batting in the second Test in South Africa last week."
In other match action, India face the West Indies on Friday in Visakhapatnam, the second of their five-match one-day series.
India needed 11 runs to win off the last 23 runs but fell short.
"There is no excuse for anybody not scoring runs," he told the Hindustan Times.
"We have to back our batting."