"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.
"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 million euros ($50.4m), including five million in potential add-ons.
Later, the Catalans confirmed the move for the 2020 Champions League winner.
"Barcelona and Bayern Munich have reached an agreement in principle for the transfer of Robert Lewandowski, dependent on the player passing a medical and contracts being signed," they said in a statement.
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."
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.
- Abysmal debt -
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 euro from Leeds.
It makes for a very generous transfer window for a club who suffered from an abysmal debt, exceeding one billion euros, a few months ago.
Double European top scorer, Lewandowski, who turns 34 next month, can bring experience to supervise a very young group, carried by Ansu Fati, Pedri, Gavi and Ferran Torres.
Lewandowski joined Bayern in 2014, scoring 344 goals in 375 competitive matches and broke the Bundesliga single-season scoring record.
He won the Bundesliga in each of his eight seasons with the club as well as the Champions League, the Club World Cup and three German Cups.
Last season, "Lewy" scored 42 goals in 50 matches in all competitions, including 35 goals in 34 league matches and 13 goals in 10 Champions League games.
The striker's official presentation as a Barcelona player is not expected to take place until they return to Catalonia in early August.
(For more sports news and updates, follow Ahram Online Sports on Twitter at @AO_Sports and on Facebook at AhramOnlineSports.)