Nikola Zigic put Birmingham through to their first Carling Cup semi-final for nine years and earned his side revenge over Aston Villa manager Gerard Houllier as the hard-fought derby game was marred by ugly scenes at the end.
Thousands of Blues fans charged towards the Villa supporters and dozens of missiles and some flares were thrown before order was restored and City can expect to face Football Association action.
Zigic's deflected shot five minutes from time settled the tie after Gabriel Agbonlahor had cancelled out Sebastian Larsson's early penalty.
Houllier had been Liverpool manager when they defeated Blues in the 2001 final and Villa were the better side for long periods.
But they were unable to deny City their first win over their local rivals for five-and-a-half years.
Blues striker Cameron Jerome had the first shot on goal after being found in space by Keith Fahey.
But Villa keeper Brad Friedel had his body behind the low drive from the former England Under-21 striker.
Villa were the first to settle and Zigic leared a goal-bound header from James Collins from a Stewart Downing corner.
But then Birmingham took the lead against the run of play after 10 minutes through a Larsson penalty.
Jerome turned the ball into Lee Bowyer and he was brought down by Villa skipper Richard Dunne.
Up stepped Larsson to drill a low penalty past Friedel who went to his right.
The home side could have doubled their lead after 23 minutes.
Larsson's low cross found Zigic unmarked but his first touch was dreadful and the ball bounced away from the Serbia international.
Birmingham thought they had doubled their lead after 28 minutes.
Larsson's corner fell into the path of Zigic whose low shot was dragged back by Friedel when replays suggested it may have crossed the line.
But one of the assistants raised his flag with Liam Ridgewell adjudged to be in an offside position.
Villa took advantage of this good fortune and after 30 minutes Agbonlahor struck at St Andrew's for the third successive game to bring his side back on level terms.
Jonathan Hogg threaded the ball into the path of Agbonlahor and his low cross shot flew past Ben Foster into the corner of the net.
Birmingham had a chance to instantly regain the lead when Jerome found himself with only Friedel to beat.
But he lofted the ball over the veteran goalkeeper and wide of the far post.
City defender Scott Dann became the first player to be yellow carded after 48 minutes for a late challenge on Agbonlahor near the halfway line.
Friedel did well to block a near-post cross from Fahey when under pressure from Jerome.
Foster went down to his left to hold onto a dipping 20-yarder from Barry Bannan.
Birmingham skipper Stephen Carr was yellow carded for a late challenge on Stephen Warnock.
Bowyer took a knock and was struggling for several minutes before being replaced after 65 minutes by Gardner.
Villa looked the more likely to snatch a winner in normal time but Gardner was only just wide with a dipping 25-yard attempt after creating the chance himself with a neat turn.
Villa came close to taking the lead when Foster parried a shot from Stephen Ireland and then Ashley Young's follow-up effort was cleared off the line by Dann.
But with five minutes remaining Zigic's deflected shot put Birmingham back in front.
Jerome made a powerful run down the right and his low cross found Zigic whose shot deflected off Luke Young and looped over Friedel.
Villa almost rescued the tie when Ciaran Clark headed just over from Downing's cross.
But the final whistle was the cue for the ugly scenes and police had to form a solid barrier between the two sets of fans.Reuse content