Huddersfield and Barnsley produced a thrilling draw as both sides escaped relegation on an afternoon of high drama at the John Smith's Stadium.
Scores here and elsewhere had both teams going down at different points, but Peterborough's 3-2 loss at Crystal Palace meant they drop into League One.
Chris O'Grady's low shot had put Barnsley in front, only for Jermaine Beckford to equalise for the hosts.
Jason Scotland restored Barnsley's lead but James Vaughan had the final word.
Vaughan's 82nd-minute equaliser would have condemned Barnsley to League One until news filtered through that Palace had scored a third against relegation rivals Posh, at which point it appeared as though both sets of players were happy to maintain the status quo.
Narrow margins in Championship
Despite being in a position that would have sent them down during the course of the afternoon, Huddersfield finished in 19th place - 10 points off a Championship play-off place and four points clear of the bottom three
The visitors had dominated early possession and looked the more assured side, so it was no surprise when O'Grady gave them the lead in the 14th minute.
Town defender Peter Clarke slipped when Barnsley midfielder David Perkins played the ball into the penalty area and O'Grady had time to pick his spot and curl a low right-footed shot inside the far post.
Huddersfield began to get a foothold in the game, but they had to wait until the 53rd minute to equalise, substitute Danny Ward slipping the ball through for Beckford, who clipped a fine finish inside Luke Steele's left-hand post.
Scotland then headed Barnsley back in front in the 75th minute. O'Grady's deft pass sent Perkins clear down the left and his precision cross was nodded home by the former Ipswich striker to send the visiting fans into raptures. The joy did not last.
Town substitute Lee Novak had been on the pitch for only a few seconds when his pass set up Vaughan, whose low finish flew in via a deflection off Steele. Tykes midfielder Tomasz Cywka was then sent on for Dawson with five minutes left as Barnsley scrambled for one last finale.
Scotland failed to connect when poised to turn the ball home and Cywka fired straight at Smithies, but with news of Palace's late goal sending Peterborough down, both sets of players played out the last few minutes without further incident.
Barnsley manager David Flitcroft:
"Mission Impossible achieved.
"We've beaten some incredible football teams and Mission Impossible can only be achieved by special people.
"Forget the football. Forget the quality, the disparity in this league, what we've achieved there is done by a group of special people and a special management team which has achieved something quite remarkable."
Huddersfield boss Mark Robins:
"It was the hardest 90 minutes that I've ever had to endure without a doubt.
"We were a million miles from our best, but we got what we needed at the end of it.
"The game doesn't really matter. It was the outcome that counted. When you've got a cup final, you've just got to get what you need.
"The job David Flitcroft has done is nothing short of miraculous because they were dead and buried in January."
- 01 Smithies
- 02 Woods
- 05 P Clarke Booked
- 06 Gerrard
- 32 Hunt
- 04 Norwood (Ward - 46' )
- 08 Clayton
- 10 Gobern (Southern - 46' Booked )
- 07 Scannell (Novak - 80' Booked )
- 18 Vaughan
- 21 Beckford
- 13 Bennett
- 03 Dixon
- 15 Wallace
- 11 Ward
- 24 Southern
- 09 Novak
- 19 Lee
- 01 Steele
- 14 Wiseman
- 25 Cranie
- 33 Kennedy
- 07 Dawson (Cywka - 84' )
- 08 O'Brien
- 11 Perkins
- 21 Mellis Booked (Noble-Lazarus - 66' Booked )
- 13 Dagnall (Scotland - 66' )
- 23 Etuhu
- 27 O'Grady Booked
- 12 Alnwick
- 15 McNulty
- 19 Cywka
- 09 Scotland
- 16 Harewood
- 24 Noble-Lazarus
- 32 Rose
Live Text Commentary
Full Time The final whistle is blown by the referee.90:00 +1:00 Booking
Booking Caution for Chris O'Grady.90:00 +0:38
Foul by Jermaine Beckford on Martin Cranie, free kick awarded. Direct free kick taken by Luke Steele.90:00 +0:18
Tomasz Cywka takes a shot. Save by Alex Smithies.88:48
Corner taken by Reuben Noble-Lazarus played to the near post, Lee Novak makes a clearance.88:10
James Vaughan takes a shot. Luke Steele makes a save.87:37
Shot from just outside the box by Jim O'Brien misses to the right of the goal.85:57
Alex Smithies restarts play with the free kick.85:57 Booking
Booking Lee Novak booked.85:33
Free kick awarded for an unfair challenge on Peter Clarke by Chris O'Grady.85:00
Chris O'Grady concedes a free kick for a foul on Keith Southern. Peter Clarke takes the direct free kick.83:25 Substitution
Substitution Tomasz Cywka comes on in place of Stephen Dawson.82:15
Tom Kennedy crosses the ball in from the free kick, Peter Clarke makes a clearance.82:15 Booking
Booking Peter Clarke receives a caution.82:02
Free kick awarded for a foul by Peter Clarke on Chris O'Grady.80:38
Assist on the goal came from Lee Novak.80:38 Goal scored
Goal! - James Vaughan - Huddersfld 2 - 2 Barnsley James Vaughan scores a goal from just inside the area high into the middle of the goal. Huddersfield 2-2 Barnsley.79:42
Direct free kick taken by Jim O'Brien.79:42 Substitution
Substitution Lee Novak is brought on as a substitute for Sean Scannell.79:42
James Vaughan is ruled offside.
Unfair challenge on Keith Southern by Kelvin Etuhu results in a free kick. Direct free kick taken by Calum Woods.73:31
Assist by David Perkins.73:31 Goal scored
Goal! - Jason Scotland - Huddersfld 1 - 2 Barnsley Jason Scotland grabs a headed goal from inside the six-yard box. Huddersfield 1-2 Barnsley.72:30 Booking
Booking The referee cautions Reuben Noble-Lazarus for unsporting behaviour.72:01
Free kick awarded for an unfair challenge on Jason Scotland by Adam Clayton. Reuben Noble-Lazarus shoots direct from the free kick, Adam Clayton makes a clearance.68:40
James Vaughan gives away a free kick for an unfair challenge on Tom Kennedy. Tom Kennedy takes the direct free kick.66:46
David Perkins takes a shot. Save by Alex Smithies.65:23 Substitution
Substitution Jason Scotland on for Chris Dagnall.65:23 Substitution
Substitution Reuben Noble-Lazarus comes on in place of Jacob Mellis.63:14
Unfair challenge on Keith Southern by Jacob Mellis results in a free kick. Direct free kick taken by Jack Hunt.62:19
Corner taken right-footed by Jacob Mellis from the left by-line, James Vaughan manages to make a clearance.60:49
Direct free kick taken by Jim O'Brien.60:49 Booking
Booking Keith Southern is cautioned.60:44
Keith Southern concedes a free kick for a foul on Jim O'Brien.59:18
Stephen Dawson takes a shot. Alex Smithies makes a brilliant save.58:50
The referee blows for offside against Jermaine Beckford. Luke Steele takes the free kick.58:19
The ball is crossed by Jim O'Brien.55:56
Chris Dagnall takes a shot. Alex Smithies makes a save. Inswinging corner taken by Jacob Mellis.54:05
The referee blows for offside against Jermaine Beckford. Luke Steele takes the direct free kick.52:34
Assist on the goal came from Daniel Ward.52:34 Goal scored
Goal! - Jermaine Beckford - Huddersfld 1 - 1 Barnsley Jermaine Beckford finds the net with a goal from deep inside the penalty box to the bottom right corner of the goal. Huddersfield 1-1 Barnsley.51:32
The offside flag is raised against Jermaine Beckford. Free kick taken by Martin Cranie.51:03
David Perkins takes a shot. Save made by Alex Smithies.49:55
Jermaine Beckford concedes a free kick for a foul on Martin Cranie. Free kick taken by Jim O'Brien.48:18
Daniel Ward crosses the ball from the free kick left-footed from right channel, blocked by Chris Dagnall.48:18 Booking
Booking Jacob Mellis is cautioned.48:08
Foul by Jacob Mellis on Jack Hunt, free kick awarded.45:16
The offside flag is raised against Jermaine Beckford. Free kick taken by Tom Kennedy.45:01
The referee gets the second half started.45:01 Substitution
Substitution Oscar Gobern leaves the field to be replaced by Keith Southern.45:01 Substitution
Substitution Daniel Ward comes on in place of Oliver Norwood.45:00 +1:04 Half time
Half Time The ref blows to signal half-time.43:51
Corner taken by Oliver Norwood from the right by-line, Headed effort on goal by Anthony Gerrard from inside the penalty box misses to the right of the goal.42:24
The ball is crossed by Adam Clayton.41:15
Foul by Chris Dagnall on Peter Clarke, free kick awarded. Free kick taken by Adam Clayton.40:07
Effort from long range by Oliver Norwood goes wide right of the target.39:15
David Perkins challenges Oscar Gobern unfairly and gives away a free kick. Oliver Norwood takes the free kick.38:36
Effort from the edge of the penalty box by James Vaughan goes wide of the right-hand upright.37:07
Kelvin Etuhu concedes a free kick for a foul on Jack Hunt. Alex Smithies takes the direct free kick.36:32
Inswinging corner taken right-footed by Jacob Mellis from the left by-line, save made by Alex Smithies.31:57
The official flags Jermaine Beckford offside. Direct free kick taken by Martin Cranie.30:13
Free kick awarded for a foul by James Vaughan on David Perkins. Tom Kennedy restarts play with the free kick.28:45
Chris Dagnall takes a shot. Save made by Alex Smithies.27:37
Oliver Norwood crosses the ball.25:27
Foul by Oliver Norwood on Stephen Dawson, free kick awarded. Tom Kennedy takes the direct free kick.24:53
Jacob Mellis delivers the ball.23:04
Peter Clarke challenges Chris O'Grady unfairly and gives away a free kick. David Perkins takes the direct free kick.20:21
James Vaughan concedes a free kick for a foul on David Perkins. Tom Kennedy takes the free kick.17:05
Free kick awarded for a foul by Stephen Dawson on Sean Scannell. Oliver Norwood takes the direct free kick.13:53
Assist by Tom Kennedy.13:53 Goal scored
Goal! - Chris O'Grady - Huddersfld 0 - 1 Barnsley Chris O'Grady scores a goal from inside the penalty box to the bottom right corner of the goal. Huddersfield 0-1 Barnsley.11:17
The offside flag is raised against Chris Dagnall. Direct free kick taken by Anthony Gerrard.10:21
Kelvin Etuhu concedes a free kick for a foul on Oscar Gobern. Anthony Gerrard takes the free kick.8:14
Effort from the edge of the box by Chris O'Grady goes wide of the left-hand upright.6:42
Peter Clarke fouled by Chris Dagnall, the ref awards a free kick. Alex Smithies restarts play with the free kick.4:42
Free kick awarded for an unfair challenge on David Perkins by James Vaughan. Free kick taken by Martin Cranie.3:30
Chris O'Grady challenges Peter Clarke unfairly and gives away a free kick. Alex Smithies restarts play with the free kick.2:25
Jermaine Beckford challenges Martin Cranie unfairly and gives away a free kick. Luke Steele restarts play with the free kick.0:34
Inswinging corner taken from the left by-line by Kelvin Etuhu.0:00
The referee starts the match.
Live data and text provided by our data suppliers