Rotherham suffered late heartbreak as a Cardiff equaliser two minutes from time saw them relegated to League One.
Needing a win to stand a chance of staying up, the visitors got the perfect start when Lewis Wing volleyed in on eight minutes.
And with the scoreline between Derby and Sheffield Wednesday in their favour, the Millers looked set to extend their stay in the Championship.
But Marlon Pack's late curling effort condemned them to relegation.
Rotherham knew they had to win to give themselves a chance of survival and will rue missing several fantastic chances when the score was 1-0.
Failure to win in Wales means they continue their five-year run of either being promoted to, or relegated from, the Championship, while Cardiff finish eighth.
The scenario for the Millers was simple enough, they needed three points while also hoping Sheffield Wednesday would do them a favour, as they needed to also better Derby County's result against the Owls.
It has been a tricky season for Rotherham, who have one of the smallest budgets in the division and have also had to contend with a fixture backlog that has left them extremely stretched in recent weeks.
They have been playing catch-up after two coronavirus outbreaks at the club caused a string of postponements, meaning they played nine times in April, picking up only four points.
Cardiff certainly had less to play for than the visitors, who started with excellent intensity.
Hopes on a Wing and prayer
The only bad thing about the first half for Rotherham was their inability to turn their huge dominance into more than a one-goal advantage.
No side with the exception of Swansea City has kept Cardiff as quiet on their own patch as the Millers did in a first half where they dominated all over the pitch.
The dangerous Wing shot over, Matt Crooks saw efforts blocked and off target and captain Richard Wood headed inches wide from a corner as the Millers pushed and pushed.
Michael Smith dragged a shot just wide and Angus MacDonald still probably cannot comprehend how Dillon Phillips somehow saved his effort from close range after a corner.
However, Wing's stunning strike on eight minutes was their only breakthrough as he hammered the ball home flush on the volley from 25 yards when Perry Ng's headed clearance fell nicely for him.
The only moment of stress for the visitors came when Michael Ihiekwe could have been sent off for a late and high tackle, but the referee showed leniency and booked him.
Late heartache for Millers
Cardiff improved immediately after the interval, with Kieffer Moore firing over, while an end-to-end exchange saw Smith for Rotherham and Cardiff's Harry Wilson both have shots blocked at the last gasp, before Smith's shot from an acute angle almost caught out Phillips.
Crooks flicked just wide with a golden chance to make it 2-0, while Wing fired wide on an incisive counter-attack before curling a delightful effort inches past the post with Phillips unmoved.
Rotherham had deserved a second but football can be a cruel game and Rotherham's gruelling schedule appeared to catch up with them in the later stages, with Pack curling home through a crowded box with two minutes remaining to consign them to League One.
Cardiff defender Sol Bamba returned to action in the final seconds as he continues to recover from a cancer diagnosis.
Rotherham continue to yo-yo
Relegation for Rotherham means they have now been either promoted to or relegated from the Championship in each of the past five seasons.
The Millers were promoted back to the second tier last season after League One's season was decided on a points-per-game basis because of the coronavirus pandemic.
As is usually the case for the frugal South Yorkshire side they did not invest a large amount across the summer and a season of struggle was expected at the New York Stadium.
That is how it has proved, as Paul Warne's men spent virtually the whole season in the bottom three.
A run of four wins from six through late January and into February gave them real hope but they followed that with a run of five straight defeats, all by a single goal.
Two Covid-19 outbreaks meant they always had games in hand on the teams above them but also forced them to have to play four games in nine days in April.
They picked up four points form the first two but then lost the second two to relegation rivals Coventry and Birmingham to leave themselves with a massive task.
Ultimately Warne will be left to reflect on their inability to eke out draws from tight games. Of their 26 league defeats this season, 19 were by a single-goal margin, the most of any team in the EFL.
He will now hope he can lead the team straight back up, as he has done on the previous two occasions they have been relegated to League One.