But the 20-year-old started only five league games in the 2017-18 season and has been allowed to leave by coach Gennaro Gattuso.
Sassuolo are reported to have paid €2 million (£1.8m/$2.3m) to loan Locatelli, while the permanent deal to be completed next year is said to be worth €12m (£10.7m/$13.6m).
Milan confirmed the deal on their official website, praising the midfielder's work during his time at the Giuseppe Meazza: "AC Milan wishes Manuel the best of luck in his future sporting career, thanking him for his professionalism and commitment to the club."
Locatelli played just 63 games for Milan over the course of three seasons, with his best spell coming in 2016-17 when he featured in 25 Serie A matches, scoring twice.
He has played for Italy up to Under-21 level and will be eligible to be part of the Azzuri squad when they host the 2019 European U-21 Championship next June.