Inter had taken just a point from their last two games, falling at Cagliari last time out, and desperately needed a morale-boosting win to keep pace with AC Milan before next week’s Derby della Madonnina.
The win keeps Inter one point behind third-placed Milan who beat bottom club Chievo 2-1 on Saturday for a fifth league win in a row.
Argentina star Mauro Icardi was not present in the San Siro, remaining sidelined since being stripped of the captaincy a month ago amid a contract dispute.
The 26-year-old also remains uncertain for Thursday’s Europa League game against Eintracht Frankfurt and Sunday’s derby, both at the San Siro.
“I won’t talk about Icardi,” said coach Luciani Spalletti, “whatever I say gets translated into something else.
“I’m talking about the great goal by Politano, a great goal by Gagliardini, a great game by Lautaro.
“We should have done better at the start of the game, but we allowed the tension to choke us, and then became timid and insecure, but we’re Inter and we had to win this game.
“We have this fire within us, but every now and then it becomes a flicker.
“Once the goal went in, everyone was totally transformed and brimming with confidence.”
– Quagliarella goes top –
Spalletti’s side had been frustrated in the first half by SPAL who are just two points above the relegation zone.
Lautaro Martinez looked to have given Inter the lead after half an hour on front of 61,000 fans in the San Siro but a VAR review awarded handball.
The hosts also lost Croatian midfielder Marcelo Brozovic, who limped off, with Joao Miranda also exiting at the break with a suspected broken nose.
Politano finally broke through after 68 minutes with Gagliardini turning in a Cedric assist nine minutes later.
The race for Champions League football remains tight with Roma, Torino and Atalanta six points behind fourth-placed Inter Milan.
Torino continued their impressive form with Andrea Belotti bagging a brace to extend their winning run to three games with a 2-1 win at Frosinone.
Walter Mazzarri’s side move sixth and into the Europa League places, level on 44 points with Roma, who play at Empoli on Monday under new coach Claudio Ranieri, and Atalanta who beat Sampdoria 2-1.
Colombian Duvan Zapata broke through for the Bergamo outfit on 50 minutes and Robin Gosens scored the winner after 77 minutes.
Fabio Quagliarella had equalised for Sampdoria from the spot on 67 minutes as the 36-year-old went top of the Serie A goal-scoring charts with 20 in 27 games, one more than Juventus star Cristiano Ronaldo.
Bologna earned a valuable three points with a 2-0 win over relegation rivals Cagliari.
Erick Pulgar converted a 34th-minute penalty with Roberto Soriano adding a second on 77 minutes to give Bologna just their fourth win of the season.
Bologna remain third from bottom with Cagliari just six points clear of safety.
Download our app and read this and other great stories on the move. Available for Android and iOS.