Derby narrowly avoided relegation after a nerve-shredding finale to the Sky Bet Championship season that saw Sheffield Wednesday, Rotherham and Wycombe drop to League One.
Wayne Rooney's Derby started the final day outside the relegation places and knowing a win would ensure they stayed up, but a 3-3 draw against Wednesday proved to be enough after 90 minutes of incredible drama.
Having lost their last six games in a row, Derby looked to be in trouble after Sam Hutchinson put Wednesday ahead in first-half injury-time, a scoreline that, along with Rotherham beating Cardiff, would have seen the Millers stay up at the expense of Derby and Wednesday.
- Rooney: We can't do this again
- When does the 2021/22 EFL season start?
- Championship fixtures | table | highlights
- Get Sky Sports
But a second half packed full of twists and turns - with Derby scoring twice in three minutes to take a 2-1 lead then fighting back to 3-3 after falling behind again and facing relegation - eventually ended with the Rams staying up, thanks ultimately to a late equaliser from Cardiff that condemned Rotherham to the drop.
Martyn Waghorn scored twice for Derby, including the 78th-minute penalty that made it 3-3, as they finished one point above 22nd-placed Wycombe, whose fate was realistically sealed before the final day.
Wednesday return to the third tier after 10 years in the Championship as their six-point deduction for breaking spending rules proves to be their downfall.
How the drama unfolded at Pride Park
With such high stakes, it was perhaps not surprising that the first half was full of tension but low on quality, as neither side was able to take control of the game.
Barry Bannan shot across goal from inside the box for the visitors while Derby's Colin Kazim-Richards had a goal ruled out for offside after goalkeeper Keiren Westwood spilled a shot from Patrick Roberts into his path.
The most notable moment of the half looked like it had come elsewhere as Rotherham took the lead against Cardiff, meaning they would survive at the expense of Derby and Sheffield Wednesday.
But Wednesday then struck deep into injury-time as Kelle Roos parried Jordan Rhodes' header from a corner and Sam Hutchinson followed up to finish.
That goal put Derby deeper into the mire, but they turned things around in remarkable fashion at the start of the second half. Waghorn drew them level when he headed home before setting up Roberts to score a brilliant goal from outside the box a few minutes later.
The quickfire double had Derby out of the relegation zone again, but not for long.
Callum Paterson capitalised on a Craig Forsyth error to make it 2-2 in the 62nd minute and some more slack Derby defending from a corner was punished shortly afterwards as Julian Borner headed in on the line.
That was far from the end of the drama, though.
Chey Dunkley fouled Kamil Jozwiak in the box and Waghorn stepped up to make it 3-3 from the penalty spot just as Cardiff equalised against Rotherham.
The full-time whistle in Cardiff meant only a Wednesday winner would change the relegation picture and keep them up, but Darren Moore's side could not grab a fourth in the closing stages.
Man of the match - Martyn Waghorn
What an afternoon for Waghorn. It looked like he might have to go off early in the game after colliding with the post, but in the end he was Derby's hero.
He levelled with an excellent flicked header and then kept his nerve to score from the spot late and make it 3-3. He was left in tears after the final whistle as Derby's place in the Championship was secured for another season.
What the managers said...
Derby's Wayne Rooney: "It was a roller coaster. The 90 minutes sums up our season. A lot of difficult moments both on and off the pitch. Thankfully the season is done and we have done what we set out to do. I am delighted for the players. They have given me everything. Today at half-time I said stay calm, we have 45 minutes left we can still win the game, manage it how we need to manage it. I am really pleased for them because they put a lot of work in.
"For the fans, we will get better, I can assure them of that. It has been a very difficult season for everyone connected to the club. We need to get everything sorted as soon as possible off the pitch to give ourselves the best chance of moving forward as a club."
Sheffield Wednesday's Darren Moore: "I said to the boys they had to come here today and leave everything on the pitch and they did. It was a pulsating game and it didn't go our way. It's a wonderful club, I'm proud to be here. It's a huge task and it will take a huge effort in the roads ahead.
"The players feel low as you can imagine, you could feel the emotion out there and we face the reality of what it is. I have one head on me today, I'll have a different one tomorrow when it comes to moving forward and implementing the things we want to at the club."
Goodman: Derby must learn lessons
Sky Sports' Don Goodman: "Lady luck has smiled rather largely on Derby to survive. They needed that late goal by Cardiff and Rotherham missed so many chances. They also had the points deduction from Sheffield Wednesday too.
"Lessons have to be learned, the fact they are celebrating surviving in the Championship is not good enough for Derby. We don't know what will happen off the pitch but things need to be a whole lot better next season."
The 2021/22 Championship and League One seasons are set to start on August 7.