The 33-year-old full back, who lead Germany to World Cup glory in 2014, made his decision public after Bayern's German DFB-Pokal win over Wolfsburg on Tuesday.
The match was Lahm’s 501st appearance for the reigning Bundesliga champions.
Lahm’s decision to quit comes a year before the end of his contract.
"I can continue with my leadership style, giving my best every day, in every training, until the end of the season. I can keep doing it this season but not beyond," Lahm said, adding that he had been thinking about calling time on his career for a year or so.
"You have to keep testing yourself, you have to keep asking yourself 'how is it', day by day, week by week on the training pitch, what's the feeling you have," he said.
Lahm, is a product of the club’s youth set up and made his debut for the club in 2002.
In a glittering career he has won seven Bundesliga titles, six German cups, as well as the Champions League in 2012/13.
He made 113 appearances for Germany, scoring five goals. He retired from international football following Germany’s World Cup win in Brazil in 2014.