Mazzarri has agreed a two-year contract and moves to Milan after leaving Serie A runners-up Napoli.
Stramaccioni has paid the price for Inter's disastrous ninth-place finish in Serie A.
A club statement said: "FC Internazionale would like to thank Andrea Stramaccioni for his great commitment and professionalism demonstrated in a particularly difficult year."
The 51-year-old took Napoli to second place in Serie A this season and re-established them as a force in Italian football over his four-year spell in charge. They also won the Italian Cup last year.
Reports of Mazzari replacing Stramaccioni have been in Italian media for days.
The 37-year-old Stramaccioni surprisingly stepped up from managing Inter's youth team to take charge of the 2010 Champions League winners last March following the sacking of Claudio Ranieri.
He did a good enough job in the final stages of that season to earn himself a three-year contract.
Early this season Inter looked to be title challengers and a run of seven straight wins finished with them ending Juventus' 49-match unbeaten streak and moving a point behind the league leaders.
However, their form dropped off straight afterwards and their season was soon engulfed by a series of bad injuries to top names including Diego Milito, Dejan Stankovic, Rodrigo Palacio, Antonio Cassano and Javier Zanetti.
They finished in ninth place on 54 points after winning only five games after the mid-season break and ended the campaign with 16 defeats.
Rafa Benitez should be named as Mazzarri's successor in the next few days after his appointment was confirmed by Napoli chairman Aurelio de Laurentiis.
An official announcement will be made once Benitez has agreed terms of his exit from Chelsea, but De Laurentiis told reporters: "I've given myself a birthday gift, I've signed Benitez."
De Laurentiis later backtracked, saying he could not divulge the identity of the new coach.