Gagliardini was guilty of one of the misses of the season midway through the second half at San Siro, yet Inter – who took a 2-1 lead into half-time following goals from Romelu Lukaku and Cristiano Biraghi – seemed to have got away with it thanks to Borja Valero's 86th-minute effort.
Yet Sassuolo, who had drawn level at 2-2 following Gagliardini's miss through Domenico Berardi's spot-kick, fought back again – Magnani bundling home from two yards out.
With tempers frayed, there was still time for more drama when Milan Skriniar received a second booking for a foul on Lukas Haraslin in stoppage time as Inter squandered the chance to keep the pressure on Serie A's top two.
It took just four minutes for Sassuolo to open the scoring – Francesco Caputo finishing from Filip Djuricic's throughball.
Jeremie Boga's foul on Skriniar ended Sassuolo's resistance four minutes before the break, with Lukaku making no mistake from the resulting penalty.
Inter's tails were up and, with Sassuolo's resolve broken, the hosts had their second in the first minute of stoppage time when Biraghi lashed in from a tight angle.
Gagliardini seemed destined to put the result beyond doubt in the 64th minute, only to slam an effort against the crossbar of a gaping goal after Andrea Consigli had parried out Lukaku's low strike.
Sassuolo made their good fortune count – Berardi keeping his composure from 12 yards following Ashley Young's foul on Mert Muldur to spark late drama.
After Lukaku saw a goal ruled out for offside, Valero's close-range finish from Antonio Candreva's free-kick seemed to have handed Inter victory, but Sassuolo rallied once more, with Antonio Conte left seething as the unmarked Magnani rescued a point for the visitors.
But Inter's frustrations were compounded moments later – Skriniar receiving his marching orders for a rash tackle on Haraslin in a frantic conclusion to a thrilling clash.
What does it mean? Inter's slim title hopes fading fast
Some costly defeats prior to Serie A's suspension due to coronavirus saw Inter slip down to third, but they would have, temporarily at least, moved to within two points of Lazio – and six of Juventus – with a victory on Wednesday.
Now, they sit on 58 points, with what seems too much ground to make up in the remaining 11 fixtures.
Berardi keeps up his run against Serie A's leading sides
With his penalty, which just snuck under Samir Handanovic, Sassuolo star Berardi has now scored four goals in his last four league matches against a side in the top three, with his previous such effort coming against Inter in the reverse fixture.
Gagliardini set for the blooper reel
In terms of misses, there will surely not be many more glaring ones this season than Gagliardini's. With the entire goal to aim at, the midfielder somehow managed to hit the woodwork from inside the six-yard box, and he will likely have to face Conte's wrath after Inter’s collapse.
Key Opta Facts
Inter have conceded three goals in a single Serie A game for the first time since the reverse fixture against Sassuolo (4-3 win).
Inter have conceded three goals in a single Serie A home game for the first time since April 2018 (2-3 v Juventus).
Lukaku has scored 19 goals in Serie A this season, his second-best campaign in the top five European Leagues (only fewer than in 2016-17 with 25 goals scored for Everton in Premier League).
Valero scored his first Serie A goal for Inter at San Siro, he had scored the first three away from home.
A trip to Parma comes next for Inter on Sunday, shortly after Sassuolo face Hellas Verona.