Birmingham clinched survival in the most dramatic fashion as Paul Caddis' header three minutes into stoppage time prevented the 2011 League Cup winners from dropping into the third tier of English football for the first time in 20 years.
With 14 minutes remaining, second-half strikes from Bolton's Lee Chung-yong and Lukas Jutkiewicz had left Lee Clark's men staring down the abyss.
Yet late goals from Nikola Zigic and Caddis earned them a 2-2 draw, and Leicester's win over Doncaster therefore meant Blues, who only dropped into the bottom three for the first time this season a week ago, stayed up at the expense of Doncaster.
It meant Lee Clark's men, who were playing in the top flight just three seasons ago, can now look to rebuild in the Championship following a tumultuous campaign both on and off the field. The club is reportedly up for sale after former owner Carson Yeung was sentenced to six years in prison for money laundering, while Clark and the future of many of his players, a handful of whom are on loan deals, remains murky.
Captain Paul Robinson was back in the Blues starting line-up following suspension and Clark recalled big-earning Zigic, probably for the final time before he is released this summer.
He was involved in a bright opening patch for the visitors too with both him and Emyr Huws, the only loanee selected in Clark's XI, seeing shots blocked while Lee Novak was inches away from turning Caddis' driven cross home.
However, Birmingham failed to build on that spell and Wanderers came close with both Lee and Rob Hall narrowly missed the target with decent efforts.
Clark's men would find a second wind before the break, though, and they kept Bolton's back-up goalkeeper Andy Lonergan busy.
Twice he denied Novak with fingertip saves, the first in particular was a fine stop down to his left, and although the ex-Huddersfield forward eventually found a way past Lonergan, the whistle had already blown for Zigic's foul on David Wheater.
While Birmingham's need for victory was evident in their hurried play, the hosts were, perhaps understandably, far more ponderous with visiting goalkeeper Darren Randolph having little to do.
As the two sides headed into the tunnel at half-time, Blues knew they were going down with Doncaster drawing and Millwall winning. Yet they were surprisingly slow out of the blocks and were punished for it 12 minutes after the restart.
David Wheater was given plenty of time to pick his pass into the box and Lee span before rifling a finish into the far corner from the right-hand side of the area.
Clark responded by introducing Jordan Ibe and Federico Macheda, both part of the second batch of Birmingham loanees who had come under fire from captain Robinson for a perceived lack of effort.
Ibe at least gave them more directness out wide and Lonergan flipped the Liverpool winger's cross into Novak's path, but he could not bring the ball under his spell quickly and eventually smashed a low shot past the post.
Birmingham's attacking play got increasingly desperate and scrappy but their fans were heartened by news of a Leicester goal against Doncaster. They relayed the message that they now only needed one goal to their players but, as those chants sounded out, substitute Jutkiewicz doubled the hosts' advantage.
The Middlesbrough loanee picked up the ball on the left channel and somehow skewed a shot under Randolph's near post 14 minutes from time.
However, two minutes later, Zigic gave the travelling support hope once more when he bundled the ball over the line after a cross from the left ended up in his path.
Neil Danns should have restored Bolton's two-goal lead but blazed over the bar and with six additional minutes signalled, Birmingham had a chance.
And it was another mad sequence of events which led to their all-important equaliser in the third of those half-a-dozen minutes added on. Zigic's header was cleared off the line by Tim Ream and the ball fell kindly for Caddis to nod in from barely a yard out and spark jubilant scenes in the stands and along on the touchline.