Inter had earlier seen a goal ruled out on video review and penalty appeals waved away, while Marcelo Brozovic and Joao Miranda went off injured. The Nerazzurri remained fourth, a point behind AC Milan. The top four from Serie A qualify for the Champions League next season.
Fifth-placed Roma is six points behind and hosts Empoli on Monday. "It was important to get back to winning ways, there wasn't much space but we found the goals in the end," Inter midfielder Joao Mario said. "We did well today, the prospect of overtaking Milan by winning the derby needs to spur us on."
Inter was still without Mauro Icardi, who has not played since being stripped off his captaincy amid protracted contract negotiations. Icardi has said he has a knee injury. "I'm not going to talk anymore about Icardi, whatever I say becomes taken in a different way," Inter coach Luciano Spalletti said. "Will he play in the derby? I'm not going to respond to questions about Icardi, otherwise we won't talk about football."
Lautaro Martinez thought he had given Inter the lead after a half-hour but the referee ruled it out for handball following a pitchside review. Inter appealed for a penalty on the hour mark but the referee opted not to review Kevin Bonifazi's nudge on Antonio Candreva.
The hosts broke the deadlock in the 67th as Lautaro's pass was deflected to Politano who smashed the ball into the back of the net. The goal again went to VAR, on suspicion of offside, but it was given after a lengthy delay.
Inter sealed the match 10 minutes later when Cedric's shot turned into an assist for Gagliardini, who took a touch and fired it into the bottom left corner. LATE EQUALIZER Having seen its title chances diminish, Napoli is now in danger of losing out on second spot.
Napoli drew 1-1 at Sassuolo to leave it 18 points behind Juventus and only six ahead of Milan. It could have been worse for Napoli but Lorenzo Insigne leveled four minutes from time after a defensive error from Sassuolo captain Francesco Magnanelli, who failed to control a poor cross from Faouzi Ghoulam.
Domenico Berardi had given Sassuolo the lead seven minutes after the break. SUPER QUAGLIARELLA Veteran forward Fabio Quagliarella is giving five-time World Player of the Year Cristiano Ronaldo a run for his money at the top of the goalscoring charts.
Quagliarella scored from a penalty kick in Sampdoria's 2-1 defeat to Atalanta to take his tally to 20 for the season — a personal record for the 36-year-old Italian and one more than Ronaldo for Juventus and Milan forward Krzysztof Piatek.
Quagliarella's penalty came either side of goals for Atalanta from Duvan Zapata, his 17th of the season, and Robin Gosens. Atalanta moved seventh, level on points with Roma and Torino, with Sampdoria five points further back.
Lazio would have moved level with Atalanta by winning at Fiorentina but the game ended in a 1-1 draw. Ciro Immobile put Lazio ahead midway through the first half. Colombia striker Luis Muriel equalized in the 61st.
Lazio is in eighth place, having played one game less than Atalanta, while Fiorentina stays in 10th. OTHER MATCHES Andrea Belotti scored a second-half brace as Torino came back to win 2-1 at relegation-threatened Frosinone.
Luca Paganini had headed Frosinone in front shortly before halftime to end Torino's run of 598 minutes without conceding. Frosinone remained five points from safety, but fellow struggler Bologna moved to within one point of 17th-placed Empoli with a 2-0 win over Cagliari.
More AP soccer: https://apnews.com/apf-Soccer and https://twitter.com/AP_Sports