The German international joined City last year from Bundesliga side Hamburg in a £10.4m deal.
However, the 22-year-old failed to settle in England and made his wish for a return to Germany known earlier this summer.
Bayern had been pursuing the central defender for some time and chairman Karl-Heinz Rummenigge is pleased to have landed his target.
"There have been some intense negotiations and we have come a long way to reach a satisfactory conclusion," he said on the club's official website.
"With Jerome Boateng we have got out preferred candidate to play in central defence for Bayern Munich."
Boateng made just 16 appearances in all competitions for City last season.