The game appeared destined for extra time until late interventions by Nicolas Anelka and Jonathan Macken clinched victory for Manchester City and a place in the fourth round at home to Spurs.
Victory was especially sweet for Kevin Keegan's side as it brought to an end a miserable run of 14 games without a win.
After an untidy start by both sides it was Leicester who fashioned the first clear chance with Kevin Stuhr-Ellegaard doing well to hold Les Ferdinand's thunderous 30-yard drive.
But then the visitors broke away to take the lead with Trevor Sinclair racing down the right and crossing to the far post where the unmarked Antoine Sibierski scored with a fine diving header.
After Ferdinand had blasted a 22-yard free-kick high and wide, Anelka went close at the other end when he cut inside and tested Ian Walker with a 16-yard angled drive.
The persistent Paul Dickov created an opportunity for himself on 32 minutes when he turned smartly to hammer a shot straight at the keeper.
Anelka then threatened again with a powerful drive, forcing Walker into a sprawling save.
James Scowcroft fired narrowly wide from 20 yards after latching on to a loose ball from David Sommeil, then Matt Heath headed a Billy McKinlay free-kick straight at the keeper as Leicester exerted prolonged pressure for the first time in the game.
The home side continued to press and should have levelled on 63 minutes when an unmarked Heath headed straight at the keeper again after Dickov had crossed from the by-line.
Leicester finally found a way through on 73 minutes after Joey Barton had fouled Dickov to concede a dangerous free-kick just outside the penalty area.
Up stepped Ferdinand to blast home a low drive, with the ball taking a slight deflection off Barton, who had positioned himself at the end of the defensive wall.
With six minutes remaining Anelka squandered a great chance when he hammered a loose ball over the bar with just the keeper to beat.
But the Frenchman more than made amends for that miss, to put his side back in front with just seconds left on the clock.
Michael Tarnat hurled a long throw forward and as Walker and Frank Sinclair waited for each other to clear the danger, Anelka nipped in to lift the ball over the keeper and into the net.
Then deep in time added on, the visitors broke again, this time Barton squared the ball to find Macken free inside the box and he had the simple task of guiding the ball beyond the exposed Walker.