Birmingham confirmed their Sky Bet Championship status for another season with a 3-1 victory at Rotherham which left the home side deep in the relegation fight.
Jacques Maghoma, Jota and Kerim Mrabti scored the second-half goals which earned the win after Matt Crooks had given Rotherham the lead midway through the first half.
The win took Garry Monk's side on to 50 points, 10 clear of Rotherham in the final relegation spot with two games of the season remaining.
But, while Monk can now look to a summer of rebuilding after his club were docked nine points for breaching profitability and sustainability rules, Paul Warne faces difficult games with West Brom and Middlesbrough as Rotherham try to bridge the three-point gap to Millwall - who have a game in hand over the Millers.
Birmingham forced a third minute corner but Michael Morrison headed over at the far post from Maghoma's delivery.
Two minutes later Che Adams won a free-kick to the right of the home area but when a low ball from Jota found the Birmingham striker his shot was comfortable for Marek Rodak.
But the home side took the lead after 22 minutes when a low ball by Ryan Williams was cleared by Morrison only as far as Crooks.
He shot low into the bottom corner from 12 yards with the Birmingham captain claiming the Rotherham player had controlled the ball with his arm.
The Millers came close to a second goal with 10 minutes of the half remaining as Joe Newell's corner was headed goalwards by Semi Ajayi and the rebound was fired over by Vaulks from close range.
Lukas Juktiewicz shot wide after being played in by Jota in a rare Birmingham attack. The visitors forced successive corners just before the break but, from the second, Gary Gardner's header was wide of the target.
Birmingham started the second half in determined mood and levelled after 56 minutes as Maghoma fired home from inside the area after taking a pass from Jota and running at a crowded defence before firing across Rodak and into the corner.
Rodak kept out a Jutkiewicz shot at his near post just after the hour was Birmingham looked for a second.
It came shortly after as Adams skipped past Richard Wood and crossed low for Jota to pick his spot and guide the ball into the bottom right corner.
Harlee Dean blocked bravely as Richie Towell shot from the edge of the area with 15 minutes to go as Rotherham continued to battle for their Championship survival.
Camp was then forced to push the ball over the bar after it bounced in the area from an Ajayi header with 12 minutes remaining.
Deep into the five minutes of stoppage time Birmingham wrapped up the win as substitute Mrabti scored his first goal for the club, firing low under Rodak after being fed by Maghoma.
The managers
Paul Warne: "We won't give up. This group, I have tried to sign characters and leaders. It was a must-win game. We didn't win it so it's disappointing. We might get a win and a draw and Millwall don't pick up anything. At half-time today life was looking half full and now it looks half empty.
"They are two games that we need to get something from. I won't approach them any differently. I am very hopeful if we can pick something up on our travels at West Brom it could come down to the last game."
Garry Monk: "I think in the first half the key was they were well on top of the second balls. We changed a little bit tactically at half-time. We had much more bodies around the second balls. That changed the game.
"We have been fighting to get us safe, that's what we have been fighting for since the nine-point deduction. I am really proud of the players in what's been a really difficult season, it's been one of the toughest I've had as a manager. I can't be prouder of the team and the fans. The unity has been important for us."