Anthony Knockaert scored an injury-time goal as Leicester City booked their spot in the Championship play-offs with an incredible win at Nottingham Forest.
The Foxes trailed to Simon Cox's early shot but a deflected Matt James strike made it 1-1, before Andy King's header put the visitors 2-1 ahead.
Elliott Ward headed Forest level, but a pulsating match was settled by Knockaert's late counter-attack winner.
Bolton's failure to beat Blackpool saw City sneak the final play-off place.
Both sides knew they probably had to win to stand any chance of keeping their season alive and so it proved - although only Forest seemed to grasp that early on.
The hosts piled forward from kick-off and after nearly three minutes of pressure, Cox fired them into the lead from close range after a fine Andy Reid cross caused confusion in the area.
Leicester's play-off dates
Thursday 9 May:
Leicester v Watford (1945 BST)
Sunday 12 May:
Watford v Leicester (1230 BST)
That start should have inspired the Reds and they did initially dominate possession and territory.
But, after an abysmal opening 10 minutes by the visitors, it was all Leicester until first-half injury time - and they could easily have been leading 5-1 by then.
City's wingers Knockaert and Lloyd Dyer were behind the transformation, tormenting the Forest defence at will.
Knockaert tested Karl Darlow, Danny Collins did brilliantly to block a Dyer shot that looked destined for the far corner and both men were constantly involved.
The relentless pressure finally told when a quick corner caught Forest sleeping and James curled the ball past Darlow, with the help of a deflection.
Forest and Leicester stats
Leicester's win is their first at the City Ground since 1972.
Forest failed to reach the play-offs despite winning six of seven games after Billy Davies returned as manager. Last week's win over Millwall was their only victory in their last eight games of the season.
Leicester ended up creeping over the line after a poor end to a season which had seen them in second spot in February and well placed for automatic promotion.
Darlow then produced a fine low stop to keep out Dyer's strike after a swift counter-attack and Michael Keane had a goal-bound volley blocked by Collins following some nifty footwork.
David Nugent wasted a glorious headed chance but the goal was coming and it was no shock that Knockaert created it with his sensational dinked cross picking out King to head home from six yards.
Finally Forest responded and Henri Lansbury twice had efforts cleared off the line.
And the Reds started the second half as they had started and finished the first, another pinpoint delivery from Reid enabling Ward to tower above the away defence and head home.
The chances continued at both ends - Chris Wood miscued horribly and Nugent also went close for the Foxes, while Cox did likewise for Forest.
As the game entered its final quarter, results elsewhere meant a winner for either side would earn them a place in the play-offs.
And with the home side going all out for victory, Knockaert broke forward on a four-on-one counter-attack and found Wood whose pass was coolly converted by the French winger.
Nottingham Forest assistant manager David Kelly:
"The players were absolutely brilliant; we had a right good go at the end as we knew how the other results were going.
"We showed real pride in that performance. With 15 games to go, we were in an extremely difficult position in the league so would have taken having a chance going into the final day.
"We will work through the summer and hopefully bounce back again."
Leicester City manager Nigel Pearson:
"I can talk about positive things but it is such a fine line. We have worked hard to get an opportunity so well done to the players.
"It's been a ridiculous league this year. During the last two or three months we have not always had the fortune we probably deserved, but we had an outside chance. We did what we had to do and things worked out elsewhere.
"It's another illustration of this crazy league.
"We showed a lot of desire and control to get back in the game maybe that will give us impetus moving forward.
"Both sets of players were dead on their feet at the end. It was an emotional day. We had to try to win, we took a few risks and it worked out OK."
Full Time The referee blows for the end of the match.
Elliott Ward produces a left-footed shot from the edge of the box and misses to the right of the goal.
Effort from deep inside the area by Elliott Ward misses to the left of the goal.
David Nugent gives away a free kick for an unfair challenge on Danny Collins. Karl Darlow takes the direct free kick.
90:00 +1:22 Booking
Booking Anthony Knockaert goes into the referee's book.
Assist on the goal came from Chris Wood.
90:00 +0:23 Goal scored
Goal! - Anthony Knockaert - Nott'm For 2 - 3 Leicester Anthony Knockaert fires in a goal from inside the six-yard box low into the middle of the goal. Nottm Forest 2-3 Leicester.
Simon Cox gives away a free kick for an unfair challenge on Jeff Schlupp. Kasper Schmeichel takes the direct free kick.
Billy Sharp is ruled offside. Kasper Schmeichel restarts play with the free kick.
The offside flag is raised against Chris Wood. Chris Cohen takes the free kick.
Matty James produces a right-footed shot from outside the box and misses left.
Direct free kick taken by Jeff Schlupp.
Substitution Ben Marshall is brought on as a substitute for Michael Keane.
Chris Wood fouled by Elliott Ward, the ref awards a free kick.
Corner taken right-footed by Matty James, save by Karl Darlow. Outswinging corner taken right-footed by Matty James from the right by-line, save made by Karl Darlow.
Simon Cox takes a shot. Save by Kasper Schmeichel.
Dan Harding produces a cross.
Substitution Billy Sharp comes on in place of Adlene Guedioura.
Foul by Jeff Schlupp on Dan Harding, free kick awarded. Chris Cohen crosses the ball in from the free kick.
Harry Kane produces a cross, save made by Karl Darlow.
Substitution Lewis McGugan joins the action as a substitute, replacing Andy Reid.
Header from close range by Radoslaw Majewski misses to the right of the target.
Dan Harding handles the ball and concedes a free kick. Free kick taken by Kasper Schmeichel.
Substitution Lloyd Dyer leaves the field to be replaced by Harry Kane.
Foul by Wes Morgan on Elliott Ward, free kick awarded. Karl Darlow takes the free kick.
The ball is swung over by David Nugent, clearance by Elliott Ward. Matty James takes a outswinging corner from the right by-line to the near post, Henri Lansbury makes a clearance.
Radoslaw Majewski concedes a free kick for a foul on Liam Moore. Free kick taken by Jeff Schlupp.
Henri Lansbury takes a shot. Save by Kasper Schmeichel. Simon Cox is flagged offside by the assistant referee. Indirect free kick taken by Kasper Schmeichel.
Close range shot by Chris Wood misses to the left of the target.
Substitution Ritchie De Laet leaves the field to be replaced by Liam Moore.
Andy Reid takes a shot. Save by Kasper Schmeichel.
Assist on the goal came from Andy Reid.
49:54 Goal scored
Goal! - Elliott Ward - Nott'm For 2 - 2 Leicester Elliott Ward finds the back of the net with a headed goal from close in. Nottm Forest 2-2 Leicester.
The ball is swung over by Andy Reid,
Booking Henri Lansbury is booked.
Wes Morgan gives away a free kick for an unfair challenge on Radoslaw Majewski.
The second half kicks off.
45:00 +4:42 Half time
Half Time The half-time whistle blows.
Henri Lansbury takes a shot. Save made by Kasper Schmeichel. Inswinging corner taken by Andy Reid from the right by-line played to the near post, Andy Reid takes a inswinging corner from the right by-line to the near post, inswinging corner taken from the right by-line by Andy Reid, Elliott Ward takes a shot. Jeff Schlupp makes a clearance. Clearance made by Kasper Schmeichel.
Assist on the goal came from Anthony Knockaert.
42:01 Goal scored
Goal! - Andy King - Nott'm For 1 - 2 Leicester Andy King finds the back of the net with a headed goal from close in. Nottm Forest 1-2 Leicester.
Shot by Chris Wood from 25 yards. Karl Darlow makes a comfortable save.
Booking Caution for Wes Morgan.
Michael Keane takes a shot from 12 yards. Clearance by Danny Collins.
Effort on goal by Lloyd Dyer from 12 yards. Save by Karl Darlow. Corner taken right-footed by Matty James from the left by-line to the near post, clearance made by Henri Lansbury.
Shot from 20 yards from David Nugent. Blocked by Dan Harding. Corner taken by Matty James from the left by-line to the near post, save made by Karl Darlow.
Substitution (Nottm Forest) makes a substitution, with Radoslaw Majewski coming on for Greg Halford.
Long distance effort from Matty James misses to the left of the goal.
Matty James takes a shot. Karl Darlow makes a save.
Effort from deep inside the area by David Nugent clears the bar.
Henri Lansbury takes a shot. Save made by Kasper Schmeichel. Inswinging corner taken by Henri Lansbury.
Shot from long range by Lloyd Dyer misses to the right of the target.
Corner taken by Matty James from the right by-line to the near post, Henri Lansbury manages to make a clearance.
Lloyd Dyer provided the assist for the goal.
23:02 Goal scored
Goal! - Matty James - Nott'm For 1 - 1 Leicester A goal is scored by Matty James from just outside the penalty area to the bottom left corner of the goal. Nottm Forest 1-1 Leicester.
Lloyd Dyer sends in a cross, Danny Collins manages to make a clearance. Short corner taken by Lloyd Dyer from the left by-line.
Simon Cox gives away a free kick for an unfair challenge on Michael Keane. Free kick taken by Kasper Schmeichel.
Unfair challenge on Elliott Ward by Chris Wood results in a free kick. Direct free kick taken by Karl Darlow.
The ball is delivered by Andy Reid, Darius Henderson takes a shot. Save by Kasper Schmeichel. David Nugent takes a shot from 20 yards. Save by Karl Darlow. Inswinging corner taken by Matty James, Elliott Ward manages to make a clearance.
David Nugent challenges Dan Harding unfairly and gives away a free kick. Karl Darlow restarts play with the free kick.
Corner taken right-footed by Matty James from the right by-line, clearance made by Darius Henderson.
Shot from just outside the box by Anthony Knockaert goes over the bar.
Shot from 20 yards by Matty James. Blocked by Andy Reid. Outswinging corner taken right-footed by Andy King from the right by-line to the near post, Simon Cox manages to make a clearance.
The ball is crossed by Lloyd Dyer, Greg Halford gets a block in. Corner taken by Matty James from the left by-line to the near post.
Anthony Knockaert has an effort at goal from outside the area which misses left.
Darius Henderson challenges Andy King unfairly and gives away a free kick. Andy King takes the free kick.
Free kick awarded for a foul by Jeff Schlupp on Henri Lansbury. Andy Reid takes the free kick.
Henri Lansbury provided the assist for the goal.
2:51 Goal scored
Goal! - Simon Cox - Nott'm For 1 - 0 Leicester A goal is scored by Simon Cox from close range to the top left corner of the goal. Nottm Forest 1-0 Leicester.
Andy King gives away a free kick for an unfair challenge on Andy Reid. Shot comes in from Andy Reid from the free kick.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.