A first goalless draw in this fixture since 2004 had looked on the cards until Palacio cleverly flicked in Fredy Guarin's cross with his heel to put Inter ahead with just four minutes left.
Milan could find no answer to that strike and, as frustrations boiled over late on, they also lost midfielder Sulley Muntari to a red card for barging over Zdravko Kuzmanovic off the ball as they ended the match with 10 men and no points.
The result means Inter were left to celebrate their first league victory in over a month - and first since president Erick Thohir took over the club - and one that lifts them back up to fifth, five points behind Napoli and the final Champions League spots.
For Milan, the defeat sees them drop down in 13th spot and brought an end to their seven-match unbeaten run in all competitions.
Both sides had chances to open the scoring during a goalless first half but Palacio, Guarin, Yuto Nakatomo and Esteban Cambiasso failed to make the breakthrough for Inter, while it was a similar story for Kaka, Andrea Poli and Mattia De Sciglio at the other end.
That continued to be the case after the interval with neither side managing to make the most of several opportunities, and as the half wore on a rare scoreless match between these two sides looked on the cards.
However, Inter started to turn up the heat in the final 10 minutes with Nagatomo turning Poli in the area and bringing a diving save out of Christian Abbiati, who moments later produced another good stop to deny Palacio.
Palacio then failed to turn in the rebound, but the Argentina international need not have worried as five minutes later he netted a brilliant winner.
Guarin drilled in a low cross from the right and Palacio got ahead of Christian Zapata before flicking the ball in on the run.
Milan tried to respond but they lost Muntari to a straight red card in stoppage time and then saw a potential equaliser snatched away by the finger tips of Inter keeper Samir Handanovic, who just managed to get enough on Mario Balotelli's inswinging free-kick to flick it above the waiting Nigel De Jong's head and keep the points with his side.