A cheeky backheel from Argentinian striker Rodrigo Palacio four minutes from time secured a 1-0 win for Inter against Milan in the 'Derby della Madonnina' in Italy's Serie A on Sunday.
Inter had dropped to sixth after Verona's 4-1 win earlier but reclaimed fifth spot to sit five points off Napoli in the third Champions League qualifying place and 15 behind leaders Juventus.
Sitting in 13th place and 17 points behind third place, struggling Milan had plenty of incentive and enjoyed the lion's share of chances and possession throughout.
It took Inter until the final 20 minutes to pile on some pressure and when Palacio sent a backheel beyond the reach of Milan 'keeper Christian Abbiati in the 86th minute the Rossoneri were left lamenting their earlier misses.
Milan coach Massimiliano Allegri said: "I can't blame the lads' effort. They gave it everything. Inter had a solid game and they made the difference in the last 20 minutes."
In what was the 159th derby between the sides -- being watched by new Inter owner, Indonesian Erick Thohir -- Inter now boast 60 wins for 50 draws.
"It was one of the best goals I've seen all season," said Thohir, who completed his takeover of the club last month.
Inter coach Walter Mazzarri had been looking for Inter to end a mediocre run of results and admitted: "There were periods in which Milan had a lot of possession and space, but I liked the way we came back into the game.
"The lads showed a lot of character. It was the derby, and it could have gone either way but I think we deserved the win tonight. It would have been a pity not to take the three points tonight."
Brazil coach Luiz Felipe Scolari was among the crowd and is likely to have been buoyed by Kaka's performance as the forward continues his quest to secure a World Cup place.
Despite Milan's dominance, the visitors lacked the slice of luck that could have made all the difference with Mario Balotelli and Kaka both coming close in an enterprising first half.
Inter had struggled to find any rhythm and were in uproar on 40 minutes when claims for a penalty went unheard after Palacio tumbled under pressure from Cristian Zapata.
Mazzarri added: "We shouldn't have to rely on penalties, because we don't decide them. But for me it was a clear penalty."
Milan resumed in similar fashion after the restart, with Balotelli coming close twice in the space of a few minutes.
But those proved to be Milan's best chances of the half and just when a draw looked to be on the cards, Inter stepped up the tempo.
In the final 10 minutes Abbiati pulled off a superb save down low after Palacio had turned and shot from six metres, but the veteran 'keeper could do little when Palacio connected with Guarin's pass in the 86th minute.
Milan finished the game with 10 men when Sulley Muntari saw red for a needless foul on late Kuzmanovic.
Earlier, Juventus conceded their first goal in nine games but saw Carlos Tevez, Paul Pogba, Fernando Llorente and Arturo Vidal all hit the net in a 4-1 win away to Atalanta.
Roma had no trouble disposing of basement side Catania, with Mehdi Benatia hitting a brace and Mattia Destro and Gervinho adding one apiece in a 4-0 win at the Olympic Stadium.
Juventus's 15th win in 17 games means Antonio Conte's men will enjoy a five-point lead over Roma during the Christmas break.
The champions host Roma on January 5, and Llorente said: "Now we'll try to enjoy some holidays before starting to prepare for the visit of Roma."
Roma have a five-point lead on Napoli, who saw Fiorentina edge to within three points of third place after Giuseppe Rossi hit an 80th-minute winner for La Viola away to struggling Sassuolo.
"In the second half we were great, that's the Roma I want to see all the time," said Roma coach Rudi Garcia.