The Brazil international passed a medical on Monday after being granted permission to travel to Turin by the Bundesliga champions.
Juve revealed the retain an option to sign Costa outright for a further €40m.
“We had serious and constructive talks with the people in charge at Juventus,” Bayern chairman Karl-Heinz Rummenigge told the club’s official website.
“All the financial requirements of FC Bayern were fulfilled.
“I want to thank Douglas for his achievements. After two successful years and four titles, he wanted to take on a different challenge.
“We have accepted this and wish him and all his family the best for the future in Italy.”
Costa follows Rodrigo Bentancur in signing for Juve in the transfer window, while Medhi Benatia and Juan Cuadrado have agreed permanent moves to the club following loans last season.
The winger made 34 appearances in all competitions last season under Carlo Ancelotti, despite admitting in February that he was unsettled in Munich.
He won two Bundesliga titles, the DFB-Pokal and the DFL-Supercup following a move from Shakhtar Donetsk in 2015 for a reported fee of €30m.