The development brings to an end speculation that Red Bull’s head of sport and development Ralph Ragnick will be taking over at the San Siro at the end of the season.
Pioli was appointed Milan manager in October last year, replacing Marco Giampaolo after a difficult start to the season.
The Rosonerri have impressed since the season resumed last month, with Tuesday’s 2-1 win at Sassuolo making in 10 games unbeaten in all competitions.
"I am happy and proud of the trust I have received from AC Milan," Pioli said in a statement.
"I want to thank everyone, including our fans, who we are really missing at the stadium, but are always close and supportive. As I have said many times, our future is today: we must be focused and determined, be united and play as one. We are at the beginning of an extraordinary path. If we keep working this way, we will grow and be more and more competitive."
CEO Ivan Gazidis said: "Stefano has shown he can deliver the vision of football we have for our club - exciting, progressive and passionate.
"This is not a decision based on recent victories, but one based on how Stefano has built team spirit and unity of purpose, the way he has improved the performances of the individual players and the collective team, the way he has embraced our vision and the way he has represented himself and the club's values."
AC Milan are fifth on the Serie A table with three games to go.