Hafeez, who made his international debut in 2003 in an ODI versus Zimbabwe, played his last international game against Australia in the T20 World Cup semifinal that his side lost last November. He initially had announced that the 2020 T20 World Cup would be his last assignment, but the postponement of the tournament due to COVID-19 extended his stay with the side. He ended his career having played 55 Tests, 218 ODIs and 119 T20Is accumulating 12,780 runs across formats and 253 wickets.
"Today I say goodbye to international cricket with pride and satisfaction," Hafeez said. "In fact, I have earned and accomplished more than I had initially envisaged and for that, I am thankful to all my fellow cricketers, captains, support staff and the Pakistan Cricket Board who helped me out during my career.
"I am extremely fortunate, lucky and proud to have been considered worthy of donning the national kit with Pakistan emblem for 18 years. My country and my team have always been at my forefront and therefore, every time I stepped on to the field, I tried to raise their profile and image by playing hard and tough but within the rich traditions of spirit of cricket.
"When you have a professional career as long as mine, you're bound to have your share of highs and lows, and I was no different. Results apart, I can say with conviction that I had more highs as I had the privilege of playing with and against some of the finest exponents of the bat and the ball of my era."
Earlier, Hafeez had retired from Test cricket in December 2018. He has subsequently been overlooked for ODIs after the 2019 World Cup with his last game coming against Bangladesh at Lord's.
Hafeez has the highest number of T20 World Cup appearances, having led Pakistan to the semifinal in the 2012 World T20. He also led the side in 2014 when Pakistan were ousted in the group stage. As captain in T20Is, he led Pakistan to 18 wins in 29 games with 11 losses.
"Hafeez has been a wholehearted cricketer who worked tirelessly at his game to have a long and fruitful career," said PCB Chairman Ramiz Raja. "His game evolved with time, adjusting to different formats quite intelligently. Later in his career, he became a T20 specialist, where he was never out of touch with modern demands of this testing format. His batsmanship took a sprightly turn, nailing sixes almost at will.
"He has worn the green blazer with pride for which we at the PCB are thankful. I wish him best of luck for his future life and thank him again for his magnificent contribution to Pakistan cricket."