The batting all-rounder made his debut in the five-day format in August 2003 against Bangladesh and will call it a day after his 55th Test.
Hafeez has scored 3,644 runs and taken 53 wickets from his 54 matches to date, and the PCB announced his retirement on Twitter coupled with a video from the 38-year-old.
"All-round @MHafeez22 announces [his] retirement from Test cricket," the PCB wrote on Twitter.
MORE: Usman Khawaja calls for privacy after police arrest and charge brother |
Hafeez made just 39 runs from four innings in the first two Tests in the ongoing series against New Zealand, while he was bowled for a duck in Pakistan's reply to New Zealand's 274 in the final contest.
It was reported that Hafeez was close to retiring in August after having his central contract downgraded, but he was persuaded to continue.