The 41-year-old made 34 appearances for Porto during the 2023-24 campaign, but he did not sign a new contract with the Portuguese giants and therefore became a free agent at the end of June.
Pepe was a vital player for Portugal at Euro 2024, meanwhile, making four appearances at the competition, including the full 120 minutes of the quarter-finals against France.
The centre-back became the oldest player to appear at a European Championship finals over the summer, and it had been thought that he would play on for at least another campaign.
However, Pepe has confirmed his retirement, bringing an end to a professional career which started in 2001.
Pepe announces retirement from professional football
"I want to thank God for giving me the wisdom to be able to continue my journey," Pepe said in a video on social media.
"I can't help but also thank all the presidents who bet and believed in me to be able to perform my work. To all the employees of all the clubs I've been to, who are the soul and essence of the clubs and the national team.
"And I want to thank everyone in the background. I want to leave a thank you and a hug of gratitude for all of you. And thank you all very much."
Pepe began his professional career at Maritimo before moving to Porto in 2004, representing the club for three seasons before making a high-profile switch to Real Madrid in 2007.
Pepe won three Champions League titles at Real Madrid
Pepe featured on 334 occasions for Real Madrid in all competitions, scoring 15 goals and registering 20 assists in the process, winning three La Liga titles, two Copa del Rey trophies and three Champions Leagues.
The defender's time at Bernanbeu came to an end in the summer of 2017, and he then turned out for Besiktas between 2017 and 2018 ahead of a return to Porto in 2019.
In total, Pepe made 288 appearances for Porto, scoring 17 goals and registering 11 assists, winning four Primeira Liga titles, while he helped Portugal win Euro 2016 and the 2018-19 UEFA Nations League.
His former Real Madrid and Portugal teammate Cristiano Ronaldo posted on Instagram: "We won everything there was to win on the pitch, but the biggest triumph is the friendship and the respect I have for you. You're unique, my brother. Thank you for so much."
Pepe retires with a club record of 42 goals and 36 assists in 737 appearances in all competitions.