The 27-year-old, who cost the Black Cats a reported £10m from Liverpool in 2015, linked up with the Rossoneri on a season-long loan last summer which included the option to buy.
Agent Roberto De Fanti is quoted by the Sunderland Echo as saying: "Yes, from the first of July he will be a player owned by the Rossoneri club until 2021.
"I would say Borini has had a positive season, given that there were low expectations when he arrived. He has proven to be worthy of Milan.
"Fabio is an exemplary professional and never seeks controversy, despite being played in several different roles across the pitch. He has worked very hard to be an important player for the club.
"He has never had any problems with Montella or Gattuso, adapting to their different tactical systems and philosophies. Clearly, Gattuso has switched from 3-5-2 to 4-3-3, which allowed him to return to an attacking position.
"I believe that the club are very happy with what Fabio has done this season. We feel the confidence from everyone. He has been a great signing. I think he will be a Milan player for a long time to come."
Borini, who has also played for the likes of Chelsea and Roma, was believed to be on the radar of Serie A champions Juventus.