Media playback is not supported on this device
Gotze, 24, made 83 Bundesliga appearances for Dortmund before joining Bayern Munich in 2013.
The size of the deal is unknown, although reports have suggested it is in the region of £20m.
"I have since his departure in 2013, always hoped that he will one day return to us," Dortmund CEO Hans-Joachim Watzke told the club website.
Gotze helped Bayern to three Bundesliga titles, as well as scoring Germany's winning goal at the 2014 World Cup.
His move to Bayern for a reported 37m euros (£31.5m) was the most expensive German transfer at the time.
Find all the latest football transfers on our dedicated page.
Borussia Dortmund have re-signed forward Mario Gotze on a four-year deal, subject to a medical.