The Nerazzurri had a goal disallowed and lost two players to injury before winger Politano and midfielder Gagliardini struck in the space of 10 second-half minutes to lift the mood at San Siro.
Their quickfire goals ended a three-match winless streak in all competitions and reduced the gap to the third-placed Rossoneri ahead of next weekend's derby.
The hosts were already without Radja Nainggolan and Ivan Perisic and, during a frustrating first half, Luciano Spalletti must have wished Mauro Icardi was not still exiled over a contract dispute.
Lautaro Martinez threatened regularly and looked to have broken the deadlock when he skilfully fired home just after the half-hour, but a VAR review found the forward to have handled the ball in controlling Kwadwo Asamoah's pass.
Inter's irritation grew as Brozovic limped off with a thigh problem, while Miranda made way at half-time due to a suspected fractured nose.
Relief eventually arrived in the form of Politano's clever 67th-minute strike, the 25-year-old swivelling onto Martinez's deflected pass and picking out the bottom-right corner.
And, after suspicions of offside on that goal were dismissed, Inter were able to celebrate a first Serie A victory since February 17 as Gagliardini cushioned Cedric Soares' wayward shot and rifled in the 77th-minute sealer.
What does it mean? Walking wounded a problem for Spalletti
Key attacker Perisic is expected to be fit in time to face Milan but his return will only go some way to easing Spalletti's injury headaches.
Miranda's absence is easier to cover than that of Brozovic, who could be set for a prolonged stint on the sidelines alongside fellow midfielder Nainggolan.
And with Icardi yet to rejoin training, the Nerazzurri can ill afford further personnel setbacks.
Gagliardini keeps Inter going
After dominating the middle of the pitch, a third Serie A goal this season served as deserved reward for 24-year-old Gagliardini.
The rangy midfielder was imposing in the air, got on the ball regularly and looks ready to play an important role for his side with team-mates falling to injury around him.
More needed from Martinez
Star striker Icardi is no certainty to feature against either Eintracht or Milan so that means the goals must come from elsewhere and there is an expectation on young forward Martinez to produce better than he did here.
Though his finish for the disallowed goal was classy, the 21-year-old was otherwise wasteful in leading the line.
Key Opta facts
- Inter gave up five shots against SPAL, fewer than in any other match in Serie A this season.
- Only Juventus (14) have more clean sheets than Inter (13) in Serie A this season.
- Inter have won nine of their last 11 Serie A home matches (D1, L1).
- Inter have scored all their last eight home goals in Serie A in the second half.
- Inter scored their two goals from their only two shots on target in the match.
Inter entertain Eintracht in the Europa League on Thursday, three days before the Derby della Madonnina. SPAL's next assignment is a home meeting with Roma on Saturday.