Birmingham's Sky Bet Championship status was secured despite a 3-1 loss against Derby at St Andrew’s.
A mistake by Derby captain Wayne Rooney which led to Ivan Sunjic's 56th-minute equaliser appeared to make Blues safe but Charlton's defeat at Leeds removed the slim possibility of relegation.
Late goals from Morgan Whittaker and substitute Louie Sibley clinched it for the Rams after Graeme Shinnie put them ahead in the sixth minute.
Midfielder Jude Bellingham, 17 - who has signed a five-year contract with Borussia Dortmund - missed three first-half chances before departing to what appeared to be cramp in the 75th minute, seemingly in tears.
It was the third time in the last six seasons that Blues had stayed up on the last day, after escaping relegation from the Championship with 1-0 wins at Bristol City in 2016-17 and Bolton in 2014-15.
Derby win at Birmingham on final day
Birmingham made the worst possible start after conceding from Derby's opening chance, after just six minutes.
Marc Roberts made a real hash of trying to clear Chris Martin's harmless looking cross and Shinnie thumped home a first-time drive from just outside the box.
Bellingham seemed determined to sign off with a goal and he went close three times in the first half.
First he fired a shot on the turn straight at replacement goalkeeper Ben Hamer after Kelle Roos had been forced off following a collision with Lukas Jutkiewicz.
Then he went close twice within a matter of seconds just after the half hour, poking wide from close range then heading against the bar.
But Derby remained a threat on the break and Jason Knight forced Lee Camp into action with a well-struck angled drive that was turned around the post.
The Blues had a major let-off in the seventh minute of time added on before half-time.
Martyn Waghorn's chip dropped over the bar with only Camp to beat when the visitors broke swiftly on a Birmingham corner.
Rooney was at fault with the error that led to Birmingham's equaliser in the 56th minute.
The Derby captain made a hash of a clearance after unconvincing headers from Roberts then Curtis Davies following a corner and Ivan Sunjic thumped home a deflected left-foot drive from 15 yards.
Rooney was given no time to atone for his error as he was withdrawn in the 65th minute for George Evans as part of a triple substitution by manager Phillip Cocu.
Whittaker's first goal came as he stooped to head home beyond Roberts on the line after Birmingham failed to clear a free kick.
Sibley, the substitute, gave the scoreline a rather flattering look in Derby's favour when he thundered home a rising angled shot from the edge of the box in the second minute of time added on.
What the managers said...
Birmingham caretaker Steve Spooner: "To go that long without a victory is very concerning. We knew the situation when we came in and we've tried to put our stamp on it and we've seen that in the improvement in performances.
"But unfortunately we haven't had enough games (in charge) to have got that win."
Derby's Phillip Cocu: "It was what we had focused on after a difficult end to the season against top teams in the league. If you win your last game to end the season you get a positive feeling and especially now with Morgan (Whittaker) and 'Sibs' (Louie Sibley) getting their goals.
"We sat down before the game and knew we have to have the right mindset. We knew it would be tough as they needed at least a point but we pushed until the end."