The 31-year-old's dramatic loss of form has also led to him being shelved from Brazil's plans for the 2014 World Cup after he was left out of the Confederations Cup squad this year. (Agencies)
Kaka has been plagued by injuries over the last few years, including one to his left knee shortly after the 2010 World Cup.
He made only 82 league appearances during his time at Real after his 65-million-euro (USD 85.71-million) move in 2009 and rarely played anything more than a supporting role.
Milan said that Kaka, full name Ricardo Izecson dos Santos Leite, had signed a two-year contract for his return to San Siro.
The announcement of his return came two days after midfielder Kevin-Prince Boateng was surprisingly sold to Bundesliga club Schalke 04.
Milan said that Kaka, who won a World Cup winner's medal with Brazil in 2002, would arrive later on Monday on a private jet along with chief executive Adriano Galliani, almost exactly 10 years after he first set foot at the club as a fresh-faced youngster from Sao Paulo.
During his first six-year spell at the club, Kaka made an immediate impact, scoring 10 goals in his first season as he helped them to land the Serie A title.
He became one of the world's top players with his remarkable burst of speed, vision and ability to shoot from distance with either foot.
He helped Milan to win the Champions League in 2007 and was voted the World Player of the Year the same year.
His Brazil career virtually ended after the 2010 World Cup, when he was a central figure in the team even though he was not fully fit after previous injuries.
He was called up for a pair of friendlies last year and performed promisingly but has not been selected since a 1-1 draw against Russia in March, when he clearly failed to impress new coach Luiz Felipe Scolari.
The 31-year-old's dramatic loss of form has also led to him being shelved from Brazil's plans for the 2014 World Cup after he was left out of the Confederations Cup squad this year.