AC Milan have reached an agreement to re-sign Brazil forward Kaka from Real Madrid.
The 31-year-old last week revealed he wanted to leave the Bernabeu after four years - having joined from Milan for a reported 70million euros (£56million) in 2009 - and Rossoneri vice-president Adriano Galliani moved quickly to persuade the 2007 Ballon d'Or winner to return to Serie A.
A statement published on Milan's official website on Monday morning confirmed a two-year contract was in place for Kaka, who was preparing to fly to Italy at midday after Madrid sanctioned his departure.
In a surprise move given the hefty fee paid for his services in 2009, it is understood the Spanish capital club have allowed the forward to leave on a free transfer, after talks between Galliani, Real president Florentino Perez and the player lasted until the early hours of Monday morning.
Kaka was an increasingly isolated figure during the three-year tenure of Jose Mourinho and Sunday's signing of Wales winger Gareth Bale from Tottenham for a world-record 100million euros fee would have pushed the Brazilian further down the pecking order.
The Milan statement continued: "Last night after 2000 CET, thanks to the traditionally good relationship between the two clubs, Real Madrid and Milan reached and formalised an agreement for the transfer of Ricardo Kaka into Rossonero colours.
"And overnight, a little before 0300 CET in the morning, an agreement was reached with the world-class Brazilian."
After leaving Sao Paolo as a teenager in 2003, Kaka won the Champions League and one Scudetto during his six years in Milan - also landing the prestigious Ballon d'Or award in 2007 - and lifted the Primera Division trophy, the Copa del Rey and the Spanish Supercup with Real.
But, speaking after scoring twice for Madrid in Thursday's 4-0 win over Deportivo La Coruna in the Trofeo Teresa Herrera, Kaka said in AS: "I want to go.
"I think now is the right time for me and for the club to leave amicably. I've spoken with (Madrid coach Carlo) Ancelotti and with the club - they all know.
"My father is talking now with the club to try to resolve this situation.
"Things are now difficult for me in the team and the club know what I want. It's my obligation to work hard and continue training, but my father is already working to see if something comes up. I think that it's best for me and for the club."
Kaka has also scored 29 goals in 87 appearances for Brazil and has represented the Selecao at three World Cups.