Afridi, 36, quit as captain on Sunday after Pakistan lost three of their four pool matches at the World Twenty20 and failed to reach the semi-finals.
Sarfraz, 28, was made vice-captain of Pakistan's ODI and Twenty20 international squads last year, and the Pakistan Cricket Board named him as Afridi's successor on Tuesday.
"His appointment is open-ended," said PCB chairman Shahryar Khan.
"I spoke to Sarfraz this morning and conveyed to him that he was our natural choice for this position."
Despite resigning as skipper, Afridi said he wanted to continue as a player for the Twenty20 side.
Have you added the new Top Story alerts in the BBC Sport app? Simply head to the menu in the app - and don't forget you can also add alerts for the Six Nations, cricket scores, your football team and more.
Sarfraz Ahmed has replaced Shahid Afridi as Pakistan's Twenty20 captain.