Lahm developed into a professional football player within the Bayern Munich Junior Team. He joined the team at the age of 11 after a youth coach, Jan Pienta, had scouted him several times while he was playing for the local youth team in his hometown Gern, Munich. He was already considered very talented; one of his coaches, Hermann Hummels, even stated that "If Philipp Lahm will not make it in the Bundesliga, nobody will anymore." He twice won the Bundesliga youth title, the second time as of his team, and then was introduced into the B team at the age of 17. His former amateur coach Hermann Gerland considers Lahm to be the most talented player he has ever coached and made him the captain of the B team during his second season. Up to this point Lahm played as a defensive midfielder, right midfielder or right .
On 13 November 2002, Lahm made his debut for the Bayern Munich first team as a 92nd-minute substitute in a 3–3 draw with RC Lens in the group stage of the Champions League. However, since Willy Sagnol and Bixente Lizarazu were established as Bayern's first choice full-backs, and the club's midfield was also well-staffed, Lahm made no further appearances during the 2002–03 season and was loaned to VfB Stuttgart for the 2003–04 and 2004–05 seasons to gain first team experience in the Bundesliga.
VfB Stuttgart (loan)
Lahm was originally signed as a back-up for Andreas Hinkel, who played as right back, but coach Felix Magath moved him to the left back position, on which he toppled the German international Heiko Gerber. He made his Bundesliga debut on the first day of the season 2003–04 against Hansa Rostock as he came in as a substitute left back in the 76th minute for midfielder Silvio Meissner. He made his first professional start as a left back on the fourth matchday as a 63rd-minute substitute for Gerber and his first game over the full 90 minutes followed on the sixth matchday against Borussia Dortmund. Thereafter he established himself as a regular left back for Stuttgart. On 29 September 2003, Lahm made his first Champions League appearance as a starter against Manchester United. On 3 April 2004, he scored his first ever Bundesliga goal in a 5–1 away win for Stuttgart against VfL Wolfsburg. During the 2003–04 season Lahm appeared for Stuttgart in 31 Bundesliga and seven Champions League matches overall and came second in the election for the .
During his second season in Stuttgart, Lahm had substantially more difficult time. After the Euro 2004 tournament and the resulting shorter vacation and pre-season training he had difficulties getting off the ground and also in conforming with the tactics and system of the new coach Matthias Sammer. However, he still made 16 Bundesliga appearances for Stuttgart before the Christmas break, 14 of them over the full 90 minutes, and six appearances in the UEFA Cup. In January 2005, Lahm suffered a stress-fracture on his right foot and was thus sidelined for four months, making his comeback on 9 April 2005, against FC Schalke 04. Only around five weeks later, he was injured again, this time suffering a torn cruciate ligament which ended his season and simultaneously his career in Stuttgart.
In July 2005, Lahm returned to Bayern Munich. However, the torn cruciate ligament he had suffered just before his return forced him to start his professional time in FC Bayern on rehabilitation. He returned to the field at the end of November playing first twice for the B team and thereafter making his first professional Bundesliga appearance for Bayern in November 2005 against Arminia Bielefeld. During the 2005–06 season he appeared for Bayern 20 times in the Bundesliga and thrice in the Champions League, contending over field-time evenly with Bixente Lizarazu.
During the season 2006–07, Lahm played in all of Bayern's 34 Bundesliga games and in nine of the ten Champions League games and was only substituted twice, mainly because Lahm was the only left back in the team but also due to his sufficiently solid performances during a season that was one of the worst for Bayern in many years. On 20 August 2006, in Bayern's first away match of the season, a 2–1 win over VfL Bochum, he scored his first goal for the club.
For the 2007–08 season, Bayern bought the German international left back Marcell Jansen and Lahm was supposed to revert to right, both to accommodate Jansen and to replace French right back Willy Sagnol. Due to injuries (both his and Jansen's) he still mainly ended up playing left for Bayern and remained left for the end of the season, although he uttered his wish to play on right several times during the year 2008. During the whole season there were various rumors suggesting that Lahm would leave Bayern in the summer of 2008 to join FC Barcelona and the transfer seemed to be almost a done deal. However, on 16 May 2008 FC Bayern signed a new contract with Lahm. His new contract kept him in Munich through 20 June 2012.
Lahm had his most prolific goalscoring season in 2008–09, scoring three times in the Bundesliga and once in the DFB-Pokal. However, the season was a poor one for Bayern, leading to the sacking of head coach Jürgen Klinsmann after less than a year in charge.
On 8 November 2009, Lahm was given the highest fine in the history of Bayern Munich to date (estimated to be over €25,000) after giving an unauthorised interview in the Süddeutsche Zeitung. He criticised the transfer policy of the club and the lack of game philosophy and strategic planning. Back in May 2008 Lahm had turned down lucrative offers from Manchester United and F.C. Barcelona to stay with Bayern as club president Uli Hoeneß promised to build a team that could challenge in Europe. This incident drew mixed reactions from fans and the media, both local and foreign, with some saying that Lahm should have kept his opinions to himself and others praising him for his honesty. Although he was fined and heavily criticised by the club hierarchy, he kept his place in the Bayern starting line-up and went on to have a good season.
During the 2009–10 season under the new coach Louis van Gaal, Lahm was able to play in his preferred position as a right back. After some difficulties in early games he played one of his best seasons ever, forming an excellent partnership on the right wing with Arjen Robben, scoring one goal and giving 12 assists in all of his games. Lahm was also chosen as vice-captain by Van Gaal, and played full-time in all of Bayern's competitive matches apart from the first-round game in the DFB-Pokal. Bayern went on to win the league and cup and reached the 2010 UEFA Champions League Final, where Lahm played 90 minutes at right-back as they lost to Inter Milan 2–0.
After the departure of captain Mark van Bommel in January 2011, Lahm was made the new captain for the remainder of the 2010–11 season and eventually named club captain.
On 19 May 2012, Lahm captained Bayern in the 2012 UEFA Champions League Final against Chelsea at the Allianz Arena. He scored the team's first penalty in the shootout but Bayern finished as runner-up for the second time in three seasons.
In the 2012–13 season, Lahm captained Bayern to an historic of the Bundesliga, DFB-Pokal and Champions League. In the final of the Champions League on 25 May 2013, Lahm helped his side to a 2–1 victory over fellow Bundesliga side Borussia Dortmund at historic Wembley Stadium in London. After the game, he revealed how happy he was at winning the title, saying "It's incredible – a huge joy and huge relief. The pressure was enormous after losing in the Champions League final twice."
From the start of the 2013–14 season, under new manager Pep Guardiola, Lahm has been utilised as a defensive midfielder. Guardiola said of Lahm: "[He] is perhaps the most intelligent player I have ever trained in my career. He is at another level." That season brought a new milestone for Lahm and the club, as he captained Bayern to a record 24th Bundesliga title and the earliest league championship in Bundesliga history, retaining the title with seven games to spare, which beat the mark set by the club in the previous season.
In June 2014, Lahm signed a new contract keeping him at Bayern until 2018. On 18 October, he scored the first brace of his career in a 6–0 defeat of SV Werder Bremen in the Bundesliga. On 26 April 2015, Bayern were confirmed as Bundesliga champions for the third consecutive season, giving Lahm the seventh league championship of his career.
On 28 April 2015, Lahm was one of four Bayern players to miss in a 2–0 penalty shootout defeat to Borussia Dortmund in the DFB-Pokal semi-final.
Leading up to the 2015–16 season, Bayern head coach Pep Guardiola stated that Lahm could return to his role at fullback with the arrivals Arturo Vidal and Joshua Kimmich.
On 24 February 2016, Lahm made his 100th UEFA Champions League appearance in a 2–2 draw with Juventus in Turin. This made him the 28th player to make 100 appearances in the competition and the second German, after former Bayern teammate Oliver Kahn. He equaled Kahn's record "in Germany" of 103 matches on 13 April 2016. The 2015–16 season ended with Lahm captaining Bayern to a fourth consecutive Bundesliga title; the first time a team had won four back-to-back championships in the competition's history.
On 4 February 2017, Lahm made his 500th appearance for FC Bayern in a 1–1 Bundesliga draw with Schalke 04. Three days later, Lahm confirmed that he would be retiring at the end of the 2016–17 season. He had rejected an offer from the club to become a sporting director.
On 20 May 2017, Lahm, along with teammate Xabi Alonso, made their final career appearance before retiring, Lahm captaining Bayern as they ended the season as champions for the fifth consecutive year. He was substituted in the 87th minute and received a standing ovation from the Allianz Arena crowd in a 4–1 win over SC Freiburg. It was confirmed on 19 July that Manuel Neuer will succeed Lahm as club captain.
Lahm became the 17th player to enter Bayern Munich's Hall of Fame in 27 May 2017; he won eight Bundesliga titles and the Champions League while playing for the club.