Andriy Shevchenko fired an 87th-minute equaliser and Frank Lampard completed a hat-trick with an injury-time winner to keep the holders in the competition.
Chelsea had led 2-1 at the interval thanks to a brace from England midfielder Lampard after Leicester had taken the lead in the sixth minute through captain Gareth McAuley.
But City stormed back to lead 3-2 with two goals in five second-half minutes from substitute Dudley Campbell and Carl Cort before Chelsea's amazing finish.
• Grant relieved after Cup scare
A night of high drama began when McAuley rose unchallenged to head home a cross from Matt Fryatt after the City striker had collected a quick free-kick from Shaun Newton.
Chelsea lacked the usual free-flowing style having made seven changes to the line-up that demolished Manchester City 6-0 in the Barclays Premier League on Saturday.
Claudio Pizarro, who had replaced Didier Drogba in attack, was the first Chelsea player to try his luck with a speculative 25-yard effort in the 17th minute.
But his low drive failed to trouble Marton Fulop although the City goalkeeper was picking the ball out of the net moments later.
The scorer was England midfielder Lampard who finished off a fine three-man move to haul Chelsea level.
Lampard failed to hit the net in the 6-0 drubbing of Manchester City despite producing an inspirational performance in midfield.
But he made no mistake from eight yards when Belletti's cross was headed back into the danger area by Scott Sinclair.
Chelsea were now in the ascendancy with Pizarro proving to be a handful for McAuley.
In the 23rd minute, Chelsea's Steve Sidwell was shown the yellow card for a challenge on City's James Chambers who required lengthy treatment before being allowed to continue.
In the 27th minute Leicester had a lucky escape when goalscorer McAuley's poor back pass to Fulop was intercepted by the lurking Shevchenko.
However, although the Ukraine striker whipped the ball off the feet of Fulop, he failed to find the open net and Leicester's defence recovered to clear the danger.
Lampard then struck for a second time when Sinclair's low cross bobbled loose to the England midfielder and he sidefooted a volley home from eight yards in the 30th minute.
Chelsea continued to press for further goals as coach Avram Grant's new attacking style began to get the better of the Championship side.
City demonstrated they were still capable of producing a threat on the counter attack when Tal Ben Haim was booked for bringing down Fryatt as the Leicester striker threatened to go clear of the Chelsea defence.
But it was Chelsea who remained in control with Belletti getting forward at every opportunity on the right flank to support Shaun Wright-Phillips.
Leicester ran out of steam the longer the half went on and that left Chelsea free to expose the gaps in their defence.
However, despite their dominance, the Barclays Premier League side were given a scare just before the break when Carlo Cudicini fluffed a shot from Fryatt only for the City striker to be flagged offside.
Chelsea lost right-back Paulo Ferreira just after half-time with what appeared to be an injury to his right ankle. He was replaced by winger Florent Malouda.
Leicester, despite being outplayed for the majority of the first half, enjoyed most of the early spells of possession after the restart.
In the 56th minute though Chelsea should have made it 3-1 when Lampard and Pizarro combined before the Peruvian's shot was saved by Fulop.
Seconds later Pizarro put Sinclair through on the edge of the six-yard box but the youngster's effort was pushed on to the upright by the City 'keeper.
Fulop produced more heroics in the 63rd minute when he denied Pizarro at point-blank range after the Chelsea striker has met a cross from Wright-Phillips on the edge of the six-yard box.
Chelsea were now storming forward at every opportunity but still Leicester refused to throw-in the towel.
In the 69th minute they managed to stun Chelsea again when substitute Campbell headed Levi Porter's chip over the advancing Cudicini and into the net.
Chelsea's hold on the Carling Cup became even more precarious in the 74th minute when Carl Cort put the Championship side in front.
Alan Sheehan's free-kick was missed by everyone except Cort at the far post and he swept the ball home to the delight of the travelling fans.
But Shevchenko levelled for Chelsea in the 87th minute and in the dying seconds Lampard's header squeezed over the line to provide a dramatic winner.
Grant relieved after Cup scareChelsea coach Avram Grant praised the character of his players after they
reached the quarter-finals of the Carling Cup and stretched their unbeaten run
to seven games.
Grant said: 'It was a good game. We enjoyed the winning and scoring four
goals but we didn't like what happened in the game because we conceded three
goals.
'More importantly it showed that we have good character. I have never in my
life given up until the last moment even if we are losing 2-0.
'This is football. When we were leading 2-1 we created five chances
one-on-one with the goalkeeper. It was fantastic but we should have scored. But
that is football.
'We want to score but we don't want one goal scored against us. But it was
good football today.
'We played positive football and in the last 10 minutes the players showed
they have a big heart and good character and I like that. Sometimes it is more
important than other things.
'We want to progress our game and every game in the last month and a half we
have taken lessons from. Andriy's goal was a fantastic one at the right moment
and the right time.'
However, Grant was less forthcoming when it came to the subject of Lampard's
contract negotiations.
The England midfielder has yet to commit himself to a new long-term deal,
sparking fears he will quit the club.
Lampard bagged his first hat-trick since January with the last-minute winner
but Grant would not be drawn on the state of play over his contract, which
expires in 18 months' time.
Grant said: 'Frank is very important for the team. He likes to do things to a
high level; that is his target and our target.
'I am not involved in the money situation. They are negotiating and at the
end of the day they will find a solution. Frank wants to stay at Chelsea and
Chelsea wants Frank.
'Frank says it all the time. It is only negotiating. It is not a football
matter.'
Leicester caretaker manager Frank Burrows felt Chelsea's class told in the end
but was proud of his team's fighting qualities.
Burrows said: 'It is not often that John Terry, the captain of England, runs
onto the pitch at the end of the game and punches the air for a result against a
Championship side.
'They were the better side. The quality of passing was better than ours and
they had more possession but our hearts were as big as theirs.
'I would not change my lads' hearts for their hearts after that. You are
playing against real quality players and it is not over until it is over.
'Where we matched them and maybe shaded them was our heart and fighting
spirit. We matched Chelsea there in my opinion.
'Chelsea have not been beaten here for 60-odd games. There have been bigger
and better football clubs than Leicester which have gone away with their tails
between their legs.
'To have come so close is a bitter pill to swallow but we have to do that.'