The 28-year-old has scored 86 goals in 122 games for the Munich club which he joined before the 2014-15 season on a five-year contract from Bundesliga rivals Borussia Dortmund.
"I'm very happy the negotiations yielded a positive result and that I'll stay at Bayern for a few more years. We still have ambitious goals," the Poland captain said in a statement.
His Tweet read:
FC Bayern München chairman Karl-Heinz Rummenigge was equally delighted with the agreement as they managed to fend off the interest of several top European clubs for the hit-man.
"I'm happy we've secured the services of one of the world's best centre-forwards over the long term," Rummenegge said.
"We now have certainty that another key player will wear the FC Bayern shirt in the coming years."
After the contract was inked at the Säbener Strasse, deputy chairman Jan-Christian Dreesen added: "We had intense, but always respectful and fair discussions, so I'd like to thank Robert Lewandowski's agents for the constructive negotiations."