The France international's previous deal was due to expire at the end of this season.
Upamecano's situation led to talk of interest from the likes of Liverpool, PSG and Barcelona.
But the 27 year-old centre-half has now committed to a new deal with Bayern through to 2030.
Upamecano, who joined the team in Munich in the 2021/22 season, has won three Bundesliga titles and one German Super Cup.
He said, I’m really happy to be staying at Bayern and continuing to play in this team. We’ve got a great team and a great coach.
"We’ve got big goals together. In life, it’s always about mentality. I give my all for my teammates, in every training session, want to keep a clean sheet in every game and want to win as many titles as possible with Bayern.”
