The 51-year-old, who will take over on July 1, also has an option of a third year as part of a deal reported to be worth two million euros ($2.2 million) annually.
"Giampaolo will now coach AC Milan's first team on the first day of the new season's training at Milanello on July 9th," Milan said in a statement.
Giampaolo replaces former player Gennaro Gattuso who quit last month amid reports of financial cutbacks after leading the club to a fifth-placed finish in Serie A.
Sporting director Leonardo also left the club with former players Zvonimir Boban and Paolo Maldini brought in as part of an overhaul at the seven-time European champions.
Giampaolo led Sampdoria to ninth-place last season having previously coached Empoli, Brescia and Cagliari.
Milan will have a tight transfer budget due to Financial Fair Play restriction and are also in a legal battle with UEFA over whether or not they feature in Europe next season.
The club won the last of their 18 Serie A titles in 2011.