Kaka looks set for a return to AC Milan after the Italian club reached a deal with Real Madrid for the Brazilian.

Milan coach Massimiliano Allegri confirmed Sunday that a deal has been agreed between the clubs but adds that "it seems there's only the agreement with the player left to sort."

A move to bring Milan idol Kaka back before the start of last season fell through, as did attempts in January.

Kaka joined Madrid from Milan in 2009 for 65 million euros ($92 million). But after injuring his left knee, Kaka was never able to establish himself as a first-choice player.

The 31-year-old hasn't played in an official match since the arrival of Carlo Ancelotti, who coached him during his best seasons at Milan when he was named FIFA world player of the year in 2007.