The Brazilian international returned to the Italian club on deadline day after a four-year spell in Spain.
"I have spent four years here giving my all to the team and overcoming challenges," Kaka, 31, told the club's official website. "We won three titles during the four years I have donned the Real Madrid shirt. This great club has a special place in my heart.
"There were many difficult times, but being part of the history of a great club like Real Madrid will stay with me for the rest of my life.
"I would like to take this opportunity to thank my teammates, coaches, all the staff, the management, the president Florentino Perez, all the Real Madrid fans and those who have supported me over the years."
Kaka has signed a two-year deal with Milan, where he previously played from 2003 to 2009.