The Argentine scored with just four minutes to go to edge Walter Mazzarri's men closer to the Champions League places and leave the Rossoneri's season in tatters
Allegri's position has been called into question due to a disappointing Serie A campaign so far, but vice-president Adriano Galliani this week denied that club legend Clarence Seedorf will take over next season.
Mario Balotelli wasted several chances to give them only their fifth win in Serie A this season and he was made to pay when Argentina international Palacio won it with a cheeky flicked finish four minutes from time to take his tally to 10 league goals for the season.
Sulley Muntari was then sent off after being deemed to have barged over Zdravko Kuzmanovic to round off a miserable night for Milan.
Allegri's side are now 27 points behind leaders Juventus in 13th place heading into the mid-season break and their suffering fans have now been subjected to four defeats in their last five games against their arch-rivals.
Inter were not at their best at a sold-out San Siro, but they ground out the victory and are now a point behind fourth-placed Fiorentina.
Allegri sprung a surprise by handing young midfielder Riccardo Saponara his first start for the club and left-back Kevin Constant returned in place of Urby Emanuelson, while Riccardo Montolivo served a suspension.
The evergreen Javier Zanetti and defender Juan Jesus were recalled to the Inter starting line-up, with Ricky Alvarez banned and Andrea Ranocchia dropping to the bench.
After a frantic start, Milan started to get the upper hand and Balotelli swivelled in the area, but failed to keep his shot down nine minutes in.
Esteban Cambiasso then produced some desperate defending to scramble the ball away after Samir Handanovic had parried Kaka's left-foot strike.
Milan continued to probe, but they were almost caught napping when Yuto Nagatomo ghosted in at the back post and stooped to head over the crossbar.
Andrea Poli wasted a golden opportunity to put Allegri's side in front when he blasted over from close range after Handanovic flapped at a corner.
Inter wanted a penalty when Zapata upended Palacio six minutes before the break, but referee Paolo Mazzoleni saw nothing untoward and Cambiasso headed wide of the far post on the stroke of half-time.
Milan lost Constant to injury during the break, so Netherlands international Emanuelson came on to replace him.
Balotelli came close to an opening goal six minutes after the break when he cut in from the left and then forced Handanovic to make a fine reflex save, while the enigmatic Italy striker was thwarted again moments later with a shot that was deflected just wide of the near post.
The former Manchester City man's frustrations continued when he was unable to get a decent contact on Kaka's inviting free-kick after 66 minutes, as the breakthrough proved to be elusive.
Balotelli was certainly not short of confidence, though, as he fired in an audacious long-range free-kick that drifted wide of the far post.
Christian Abbiati got down well to deny Palacio 10 minutes from time and the Argentina man failed to tap home from close range as the ball was sent back across goal.
But he made amends four minutes from time with a delicate finish after Fredy Guarin picked him out with a centre.
Muntari was then dismissed two minutes into time added on for shoving Kuzmanovic to add insult to injury for Milan.