Ribery, 39, announced the decision in a video posted on social media in which the Salernitana player also thanked his family and fans.
"The fact that I was able to play at a high level for almost 20 years and to have this career is also because, even in difficult times, you were always there," Ribery said. "You have given me the strength to live this incredible adventure.
"But today, despite the efforts I have made over the last three months, the pain in my knee has only worsened and the doctors are clear: I have no choice but to stop playing. So I have to end my career as a professional player."
Ribery played for a number of clubs, including Marseille and Fiorentina, but his most successful period was at Bayern, where he won nine Bundesliga titles, six German Cups and the Champions League during a 12-year spell.
He also played for France in their defeat to Italy in the 2006 World Cup final.
- Notebook: The inside stories from world football
Ribery left Bayern on a free transfer in 2019 and played for Fiorentina for two seasons before joining Salernitana last year.
He made 23 appearances for Salernitana last season but played just twice in August this season before being injured again.
Salernitana confirmed they had mutually agreed to end the winger's playing contract but added that Ribery would continue in another role at the club.
They also said he would bid farewell to the fans before Saturday's Serie A match against Spezia.
"This is the end of a chapter, my chapter as a player, but not of my professional story, you can be sure of that," Ribery concluded in his video message.
"So I will see you soon, for the beginning of a new beautiful chapter."
Salernitana coach Davide Nicola said Ribery would be part of his staff, while it is likely he will also work on his coaching licenses.
Ribery also added a second emotional post on social media.
"One thing is clear, football will remain a big part of my life," Ribery wrote.
"I hope that you will continue to support me in the future as you have always done.
"I miss it already. The ball, the pitch, the stadiums, you fans. And yet I know that I will always be close to it all. Also in the future.
"Football and me. That simply belongs together. And always will."