Mohammad Hafeez stepped down as T20 captain after the World Twenty20 in Bangladesh this year where Pakistan failed to qualify for the semi-finals for the first time since the tournament's inception in 2007.
The Pakistan Cricket Board said the 34-year-old Afridi's appointment was for two years, till the World Twenty20 in 2016.
The board also put an end to the ongoing speculation on the future of Misbah-ul-Haq by confirming the 40-year-old as the Test and ODI captain till the 50-over World Cup next year.
"I consulted Cricket Committee and my Board members before announcing these decisions. I wish both Afridi and Misbah very good luck in their upcoming assignments," PCB chairman Shaharyar Khan told reporters.
The PCB has, however, deferred naming the squad for next month's series against Australia in the UAE.
Afridi was ODI and T20 captain in 2010-2011 and also led them in the last World Cup before he had a fall out with head coach Waqar Younis, which led to disciplinary issues and subsequently the flamboyant cricketer was sacked in May 2011.