30-year-old Wagner, who was born in Munich and spent 13 years with Bayern between 1995 and 2008, has been assigned the number two shirt on his return 'home'.
"I'm really happy. A long journey comes to an end for me as I come home to my club," the player told FCBayern.de.
"I am very happy that everything worked out. Bayern is the best club in Germany and one of the best in the world. When the offer came, I did not have to think twice."
Bayern sporting director Hasan Salihamidzic commented, "Sandro Wagner is another German international joining Bayern. We are confident that Sandro Wagner will further enhance the quality of our team through his class and experience."
Having progressed through the ranks in Munich, Wagner played regularly for Bayern II during the 2006/07 campaign and went on to play eight first-team games the following season.
From there, he joined Duisberg, Werder Bremen, Kaiserslautern, Hertha Berlin and Darmstadt, before arriving at Hoffenheim in 2016.
A late bloomer, Wagner made his senior Germany debut this year and has already scored five times in only seven international appearances.