The Polish striker was unhappy with the salary offered by Bayern and had clashed with the Bavarian club's coach Julian Nagelsmann over tactical choices.
Bayern Munich have agreed a deal with Barcelona for the sale of Poland star Robert Lewandowski to the Spanish club.
"We have a verbal agreement from Barcelona. It's good for both sides that we have clarity," Bayern president Herbert Hainer said on the club's Twitter account on Saturday.
"Robert is a very deserving player, he has won everything with us. We are incredibly grateful to him."
Bayern did not give details but Spanish and German media reported the two-time FIFA men's player of the year had agreed a four-year deal worth $50.4 million (50 million euros ), including five million in potential add-ons.
Forward Lewandowski told German television he would be joining the Barcelona squad on their tour of the United States from July 18-31.
Media reported he would undergo his medical in Miami.
The agreement between the two teams closes the standoff with the 33-year-old who said at the end of May "it is certain that my story with Bayern has come to an end."
READ MORE: Lewandowski: 'My Bayern story has come to an end'
Tensions with Bayern
Bayern had only offered Lewandowski a one-year extension to his contract, which expires in the summer of 2023.
He was also unhappy with the salary offered and had clashed with the Bavarian club's coach Julian Nagelsmann over tactical choices.
Although he resumed training with Bayern a few days ago, Lewandowski arrived late each time, except this Saturday, when he took the opportunity to bid farewell to his teammates.
The official presentation of the Bayern squad then took place at 1500 local time (1300GMT) without him.
With his imminent arrival, Barcelona continue to strengthen with the ambition of returning to the forefront of the European scene.
He is the club's fourth summer transfer after Ivory Coast midfielder Franck Kessie from AC Milan and Chelsea defender Andreas Christensen on a free transfer, and Brazil winger Raphinha, recruited for $70 million from Leeds.
A very generous transfer window for a club which suffered from an abysmal debt, exceeding one billion euros, a few months ago.
The striker's official presentation to Barcelona is not expected to take place until they return to Catalonia in early August.
READ MORE: Putellas, Lewandowski win top FIFA 'Best' awards