The former England captain will join the team from 7 January when the Serie A season restarts following its winter break.
Milan vice-president Adriano Galliano had revealed earlier in the day that he was due for talks with Beckham's lawyers, who were in Milan, and now a deal has been agreed.
The seven-time European champions first revealed the possibility of the loan move last week after rumours circulated that Beckham would train with the Italians during the North American Major League Soccer close-season.
The former Manchester United and Real Madrid midfielder currently plays for Los Angeles Galaxy, whom he joined 18 months ago, but needs to keep playing over winter to avoid losing match fitness and his place in the England squad.
Beckham has 107 caps for England and is the third most capped player in the country's history.