The signing took place in Madrid after the Champions League final Bayern lost 2-0 to Inter Milan on Saturday.
“We are very happy to have reached agreement on a contract extension with one of the world’s best players,” said Bayern president Karl-Heinz Rummenigge.
“It’s also a sign of Bayern Munich’s grand designs for the years to come.”
France international Ribery, now set to join up with his French teammates ahead of the World Cup finals, said he too was “very happy.”
“My family and I are very happy to stay in Munich. The club has become one big family for me,” said Ribery, who arrived in Germany from Marseille in 2007 and was under contract until 2011.
Bayern began the season warding off the attentions of European giants like Real Madrid, who were looking to sign Ribery.
The 27-year-old then suffered a series of injuries that scuppered his season, and last month he hit the headlines after being implicated in a scandal involving an underage escort girl.
The affair reportedly turned Real Madrid off Ribery’s scent. On-field frustrations, in the shape of a three-game UEFA ban for a nasty tackle during the Champions League semi-final against Lyon – which kept Ribery out of Saturday’s final against Inter Milan – soon followed.
Ribery had said he wanted to sort his club future out before the World Cup in which France are drawn in Group A alongside hosts South Africa, Uruguay and Mexico.