The club had been expected to part ways with Allegri at the end of the season following a disappointing campaign. However, they decided to act with two games remaining.
Juventus are currently fourth in Serie A after five consecutive draws but have secured a spot in next season’s Champions League. They are seven points ahead of sixth-placed Roma.
Allegri led Juventus to victory over Atalanta in the Coppa Italia final on Wednesday, securing his first trophy since returning to the club in June 2021.
However, Allegri appeared to distance himself from club directors Cristiano Giuntoli and Maurizio Scanavino after the match and did not join in the players’ celebrations with the fans.
This decision ends Allegri’s second stint as head coach, during which Juventus won just one trophy. The 2022-23 season saw them fail to qualify for European competitions.
Juventus were top of Serie A in January after a 3-0 win over Lecce, but they now trail champions Inter by 25 points and are likely to finish no higher than third.
In his first spell with Juventus from 2014 to 2019, Allegri won the Serie A title five times, reached the Champions League final twice, and secured four Coppa Italia trophies and two Supercoppa Italiana titles.
Allegri, who has been a manager for over two decades, also led Milan to the Serie A title in 2010-11.
Juventus will face Bologna on Monday and Monza in their final match of the season next weekend.