Pakistan went out from the Super-10 stage after a disappointing 84-run defeat against the West Indies on Tuesday, failing to reach the last four for the first time in five editions of the tournament since its inception in 2007.
Hafeez said he accepted responsibility for the early exit.
“I accept all the responsibility of team's failure,” Hafeez told reporters after a Pakistan Cricket Board (PCB) meeting in Lahore.
Hafeez led Pakistan to the semi-finals in the last World Twenty20 in Sri Lanka two years ago, shortly after taking over from Misbah-ul Haq.
The all-rounder, who opens both the batting and the bowling with his off-spin, said no one had forced him to quit.
“I am under no pressure and felt that I must step down as leader by taking responsibility, and it's for the PCB to decide who to lead the team,” said Hafeez.
Pakistan have no assignment before their series against Australia in October when they play two Tests, three one-days and one Twenty20 in the United Arab Emirates.
The 33-year-old said he was ready to join the ranks under any captain.
“I am ready to play under any captain as I have done my job with responsibility as captain as well as player,” he said.
Pakistan began the World Twenty20 with a defeat against arch-rivals India before winning their next two games against Australia and Bangladesh.
Hafeez said the players had made too many unforced mistakes during their defeats.
“Our players committed mistakes which led to our defeat and we take responsibility,” said Hafeez.
“I have already apologised to the nation for letting down our fans.”
Hafeez led Pakistan in 29 Twenty20 matches, winning 17 and losing 11, while one was abandoned.
Coach Moin Khan said Hafeez's decision should be praised.
“Hafeez has accepted responsibility and has stepped down so we all must praise his decision,” Khan told reporters.
Khan also urged the media and fans to back the team.
“When we won two matches they (media and fans) made us heroes, but after the West Indies defeat they made us zeroes, so they must back us in these hard times.”
All-rounder Shahid Afridi, who led Pakistan to the semi-finals of the last 50-over World Cup in India three years ago, is widely tipped to take over the captaincy.