Kaka returns to Milan, where he enjoyed the best football of his career, after leaving for the Bernabeu four years ago on a deal of around £56m.
The 31-year-old has agreed a two-year contract with the Rossonero following lengthy discussions over the weekend.
Kaka endured a frustrating time in Madrid where he spent several spells on the sidelines due to injury.
But the Brazil international will be hoping to rekindle the form in his first spell at the San Siro as he aims to represent his country when they host the World Cup next year.
Kaka said: "Four years have passed and now I'm back. It's been two weeks that I thought if I could come back, a return to Milan would be ideal for me.
"I've been dreaming of hearing the fans sing my name in San Siro again. I was very sad to leave this team and now it's great to be back. I'm very happy."