The young international will join the Bavarian giants on July 1 on a contract believed to be until 2016 - in the process becoming the most expensive German player in the history of the game.
The versatile 20-year-old, who won league titles in 2011 and 2012, is among the most talented young players in Germany and had reportedly been the target of several top European clubs, including Chelsea, Arsenal, Manchester City and Manchester United.
Goetze will be on his way to the Allianz Arena this summer after Bayern triggered the 37 million euro (£32 million) release clause in his contract, it was confirmed on Dortmund's Facebook page.
It is understood that he will be paid seven million euros (£6m) a year.
"Mario Goetze and his advisor informed Borussia Dortmund a few days ago that Goetze would like to use his get-out clause in his contract and move to Bayern Munich on July 1," Dortmund on their official website.
Dortmund's CEO Hans-Joachim Watzke said: "We are obviously disappointed beyond measure, but emphasise both Mario and advisors have behaved absolutely in line with the contract."
Bayern added a statement, which read: "FC Bayern is prepared to activate the contractual release clause agreed between Borussia Dortmund and Mario Goetze. Out of consideration for the Champions League semi-final first leg between Dortmund and Real Madrid on Wednesday 24 April, FC Bayern had intended to wait until after the match before communicating this to BVB."
Dirk Adam from Eurosport’s office in Munich said: "It really is the biggest move in Bundesliga since 2009 when Mario Gomez joined Bayern from Stuttgart for 35m euros (£30m). Only Javi Martinez’s move from Athletic Bilbao to Bayern last year was more expensive at 40m euros (£34m).
"Dortmund are losing their best player and also a key part of their future, with Goetze having been a part of the club since 2001. For the Bundesliga as a whole it is a bad move because Dortmund were the one and only team to challenge Bayern. Now it will be much more difficult.
"Goetze is, without doubt, one of the most talented players around, along with Marco Reus. It is the perfect move for Bayern because Goetze will replace Arjen Robben and he can play across the midfield and also as a striker. It is also an ideal move for Guardiola, with Goetze one of his favourite players."
Bayern, who have already won the Bundesliga title, have signed former Barcelona coach Pep Guardiola for next season.
The Bavarians take on Barcelona in the first leg of their Champions League semi-final on Tuesday and have reached the German Cup final as well.