Goretzka’s previous deal would have expired at the end of this season, which had seen him linked with the likes of Manchester United and Real Madrid.
The 26-year-old joined Bayern Munich from Schalke 04 in the summer of 2018 on a free transfer and has so far made 118 appearances for the Bavarians, scoring 25 goals.
Goretzka has won three Bundesliga titles, the UEFA Champions League, UEFA Super Cup, FIFA Club World Cup, two DFB-Pokals and three German Super Cups in his time at the Allianz Arena.
Goretzka told the club's official website: "With FC Bayern we have won everything there is to be won over the past three years, but it is even nicer than winning a title to confirm and repeat these successes. We want to build on this in the next few years.
"The team, the club and the environment are not only highly professional, but also familiar. This mixture is one of the guarantors of success at this club. I am very happy that I was able to extend my contract early until 2026."
Bayern Munich president Herbert Hainer added: "On the one hand, his athletic qualities are valued across Europe. On the other hand, he is a personality beyond the field of play. Goretzka is an opinion leader on and off the football pitch - and that's exactly what we like to see here at FC Bayern."