Matt Crooks opened the scoring for Paul Warne's side, before Jacques Maghoma, Jota and Kerim Mrabti secured victory at the New York Stadium
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.