Scott Dann's last-gasp strike at Blackpool earned Birmingham their first away win of the season with their 2-1 success also moving them out of the Barclays Premier League relegation zone.
Alexander Hleb pounced on a mistake by Stephen Crainey to put Blues ahead in the first half before DJ Campbell's 68th-minute equaliser.
Alex McLeish's side then sealed victory thanks to Dann's close-range effort with a minute of normal time remaining.
It was a dramatic conclusion to a pulsating game which saw the woodwork rattled once by the hosts and twice by the visitors.
Blackpool, playing at home for the first time since November 20, were slow to get out of the blocks and fortunate not to be a goal down within the opening two minutes.
Having been fed by Hleb, Liam Ridgewell sent the ball into the six-yard box for Matt Derbyshire, but with the goal at his mercy, the striker could only prod his effort wide.
Three minutes later the ball fell to Derbyshire in the area again as Cameron Jerome lashed a shot across goal but there was too much pace on it and the former Blackburn man could not capitalise.
Birmingham wasted another decent opportunity within seconds, Jerome the culprit this time as he failed to wrap his foot around Derbyshire's cut-back.
The hosts attempted to get a grip on the game and Neal Eardley rifled their first shot at goal over the bar in the 10th minute.
Matt Phillips tried to drill one but could not get much power on it and went closer soon after, connecting with Charlie Adam's free-kick at the back post but seeing his shot blocked by Ben Foster.
It seemed Blackpool had settled, but then an error by Crainey led to the visitors taking the lead.
Under little apparent pressure, Crainey inadvertently laid the ball straight to Hleb on the edge of the box, and he gleefully took advantage by beating Richard Kingson.
The Seasiders almost hit back straight away, with Phillips getting on the end of Adam's free-kick but only able to provide a glancing contact that sent the ball wide.
Gary Taylor-Fletcher tried a chip which Foster saved before Craig Gardner sliced an effort off-target at the other end.
Jerome then cracked a shot at Kingson just before the break which the Ghanaian palmed away.
Blackpool emerged from the interval looking determined to find an equaliser and Luke Varney unleashed an effort that cleared the bar five minutes after the restart.
Adam's curling shot from distance then drew a diving save out of Foster with Varney lifting the follow-up over the bar, and Phillips had a low drive blocked.
McLeish brought on Sebastian Larsson for Keith Fahey before Blackpool broke away again, Adam squaring to Campbell, who was off-balance as he shot towards Foster.
The momentum was with the hosts, but Blues then nearly made it 2-0 as Jerome dinked the ball over Kingson only to be denied by the post.
Larsson also struck the upright with a free-kick soon after, but moments later, the Seasiders were level.
Taylor-Fletcher provided a knock-down from Eardley's cross and Campbell was there to volley past Foster for his fourth goal in four games.
Tangerines boss Ian Holloway withdrew Phillips and Taylor-Fletcher for Brett Ormerod and Jason Euell and the home supporters cried out for a penalty as Ridgewell challenged Varney in the box, but referee Jon Moss waved play on.
Blackpool's substitutes were swiftly in the thick of the action as Euell volleyed at Foster before Ormerod saw his effort saved by the England stopper.
Adam then got the ball beyond Foster with an angled shot, but it came back off the far post.
Birmingham appeared to have held on for a point, but right at the death, they snatched all three.
Roger Johnson rose in the box to head down substitute Jean Beausejour's delivery and Dann fired the ball in, with Kingson's appeals for offside proving futile.
Copyright (c) PA Sport 2009, All Rights Reserved.