Robert Lewandowski is joining Barcelona in a 50 million euro deal until 2027, the Spanish club said on Tuesday.
Barca released a statement confirming the move three days after both clubs announced that a deal "in principle" had been struck for the Polish striker to move to La Liga.
"The player will sign a contract with the Club for the next four seasons. The buyout clause has been set at EUR500 million," it added.
Lewandowski, 33, has linked up with his new teammates in the United States for a series of friendlies in Miami.
He is the Catalan side's fourth signing of the summer after Franck Kessie (AC Milan) and Andreas Christensen (Chelsea), arrived as free agents while Rapinha cost 70 million euros from Leeds.
The agreement between Barca and Bayern closed the standoff with the player 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 left Bayern after eight years with one Champions League and eight Bundesliga titles.