The 27-year-old Brazilian winger has been on loan at the Serie A champions since the beginning of the season.
Bayern boss Karl-Heinz Rummenigge confirmed late Friday Costa’s departure in a sale that eclipses the Bundesliga champion’s previous record of 25 million euros for both Germany’s Toni Kroos to Real Madrid in 2014 and England’s Owen Hargreaves to Manchester United in 2007.
Costa arrived in Germany from Ukrainian club Shakhtar Donetsk in 2015 for 30 million euros. But after a successful season in Munich under Pep Guardiola he fell out of favour with the Spaniard’s successor Carlo Ancelotti.
Costa has scored one goal and made four assists in 16 matches for six-time reigning Italian champions Juventus.