Midfielder Sulley Muntari, a former Inter player, was then dismissed.
It was a first Derby della Madonnina victory for Mazzarri, who left Napoli in the summer, and the three points snapped a four-game winless streak and lifted Inter to fifth in the table.
Mazzarri jumped for joy when Palacio netted, before visibly admonishing himself.
The Tuscan later admitted bad memories of Juventus‘ late equalizer in a 1-1 draw in September had reminded him to be patient.
He told inter.it: "Yes, I celebrated when we scored but then I almost regretted it because there was still a bit left to play – I think I must have had a flashback to Inter v Juve.
"You can never let your guard down in this game. We’ve thrown away too many points by letting our concentration slip after taking the lead and it would have been a shame to do that again."
Palacio, Fredy Guarin, Yuto Nakatomo and Esteban Cambiasso all failed to make the breakthrough for Inter in a frustrating first half, while it was a similar story for Kaka, Andrea Poli and Mattia De Sciglio at the other end.
"We were too tense in the first half, and they were chasing us down well too," Mazzarri added. "Then in the second half we played the way we know how to.
"We shook ourselves up in the dressing room during the break and in the end we played a great game. It looked like it was going to be another of those days when the ball just doesn’t want to go in.
"We couldn’t quite finish off our moves."
Colombian schemer Guarin, who provided the cross for Palacio to flick home four minutes from time, has been linked to Premier League club Chelsea, among other suitors, but Mazzarri pleaded ignorance over any potential deal.
He said: "Have we already sold Guarin? Who to? That’s something you need to ask the club.
"Besides, the transfer window isn’t even open yet. We’ll take stock of things after this game.
"I don’t like playing along with these games. Guarin is improving a lot and he’s had a great season so far."
The Nerazzurro victory was a first in the league since Indonesian businessman Erick Thohir bought a controlling stake in the club and he revelled in a "magnificent night".
"I want to thank all the players for this wonderful game, and I want to thank all the fans," he said. "The 80,000 were incredible, amazing. I’m sure we’ll all have a happy Christmas now.
"It was a magnificent night. AC Milan played well, we respect them but it was a great win.
"I think Palacio scored one of the goals of the season, it was a fantastic backheel."