The arrival of the 39-year-old midfielder was confirmed by the newly-appointed Milan coach Massimiliano Allegri earlier this month.
Modric will don the number 14 jersey, as stated by Milan.
Modric, considered one of the greatest midfielders in history, announced in May that he would depart Real after the Club World Cup. He made 597 appearances for the Spanish club, winning 28 trophies, including four LaLiga titles and six Champions League titles.
He played his final match for Real on Wednesday, coming on as a substitute in the second half during a 4-0 defeat to Paris St Germain in the semi-finals of the Club World Cup.
"It's a painful conclusion... he's a legend in world football and at Real Madrid. He will be remembered for far more positive moments than the 25 minutes he played today," said Real Madrid manager Xabi Alonso after the match.
Widely regarded as Croatia's finest player ever, he has represented his country 188 times, scoring 28 goals. He won the Golden Ball at the 2018 World Cup, where he led Croatia to their first final.
He also claimed the Ballon d'Or that same year, becoming the first player other than Lionel Messi and Cristiano Ronaldo to win the prestigious award since 2007.
Modric's addition strengthens a Milan midfield that also includes Youssouf Fofana, Yunus Musah and Ruben Loftus-Cheek, with Samuele Ricci joining from Torino earlier this month.
Milan, who did not qualify for European competitions after finishing eighth in the Italian top-flight league last season, will begin their Serie A campaign against newly-promoted Cremonese on August 23.