Chasing a challenging 138-run target, Pakistan were held to the final over of the match and won on a wide off the last delivery of the match.
Skipper Mohammad Hafeez kept his cool to finish with a 37-ball 42 not out as Pakistan needed six off the final over bowled by Dawlat Zadran and one off the last delivery.
Hafeez hit two boundaries and a six during his knock and avoided any major hiccup against a fighting Afghan team.
Shehzad, who hit six boundaries during his 37-ball knock, holed out while Sharjeel miscued a drive off Mohammad Nabi in the tenth over.
More From This Section
Despite a tight line and length by Afghanistan's bowlers, Hafeez and Akmal kept their cool, taking Pakistan close to their victory target.
Akmal hit two sixes in his 28 off 23 balls.
"I think they scored what they wanted, then bowled tight and put up a good show," said Hafeez.
"I am happy with the win but we made some mistakes and need to learn from them.