Substitute Jeff Schlupp coolly converted in the 80th minute on Tuesday night after latching on to Tom Kennedy’s throughball before Jermaine Beckford grabbed his second of the night with the last kick of the game to leave the Foxes within six points of the top six.
It capped a turnaround which was just about deserved on the overall balance of play in what was an entertaining encounter, with Beckford’s simple tap-in from two yards out – his 10th of the season – cancelling out Wade Elliott’s penalty.
Kennedy was in the thick of the action for the soft spot-kick, he and Sol Bamba adjudged to have sandwiched Nikola Zigic, while the Serbian and Beckford also struck the woodwork at the King Power Stadium.
Defeat sees Birmingham drop one place to eighth and Chris Hughton will be concerned by a recent dip in form which has seen his side take just two points from four successive midlands showdowns against Nottingham Forest, Derby, Coventry and now Leicester.
The Foxes could hardly afford to drop any more points if they were to close the gap on the play-off places.
And boss Nigel Pearson was under no illusions about the importance of tonight’s clash after back-to-back away defeats, saying in the pre-match build-up: “This is a massive game for us, it’s as simple as that. We need to win it.”
Midfielder Neil Danns was first to go close against his former employers, firing inches wide from 20 yards.
But after Elliott had brought a smart save out of Kasper Schmeichel, it was the midfielder who fired Birmingham into the lead from the spot.
Referee Mick Russell felt Zigic had received a nudge in the back by Kennedy and Bamba when trying to get his head on Andros Townsend’s left-wing cross, much to the astonishment of the home side.
Pablo Ibanez, an early replacement for the injured Jonathan Spector, saw a handball decision go his way minutes later as Leicester, who had done all of the pressing prior to the opener, went in search of an equaliser.
But it was Zigic who almost doubled the visitors’ advantage on the half-hour mark, his header rebounding down off the crossbar and the wrong side of the goalline before Steven Caldwell’s follow-up was cleared away from danger.
An end-to-end encounter flowed freely and Leicester were soon on level terms, Beckford tapping home after Kennedy’s cross into the box had been directed back across goal by David Nugent and rebounded off the far post.
Elliott missed a glorious opportunity to restore Birmingham’s lead on the stroke of half-time as he could only volley across goal from four yards out.
Eighteen second-half minutes had passed before Chris Burke’s curling effort forced a parried save from Schmeichel.
Richie Wellens’ stinging drive from distance was then punched away by Boaz Myhill at the other end, Beckford unable to convert the rebound.
The former Everton marksman showed great strength to shrug off two defenders and connect with a long ball before finding the outside of a post.
But Schlupp made sure it mattered little with the winner 10 minutes from time and then Beckford, capitalising on more slow defending from Ibanez, made it three deep into injury time.