A Bruno Fernandes penalty helped Manchester United to a 2-0 win over Leicester City to send Ole Gunnar Solskjaer's side into the Champions League.
The Red Devils needed only a draw to guarantee they would finish above Leicester, who were left needing all three points due to Chelsea's 2-0 win over Wolves at Stamford Bridge.
It was talisman Fernandes who kept his cool on a nervy final day of the Premier League season at the King Power Stadium after Anthony Martial had been fouled by Jonny Evans, who was later sent off, with 19 minutes to go.
Leicester had half-chances throughout but could not find a way past David de Gea and their day was summed up by the late dismissal of Evans and a mistake by Kasper Schmeichel that allowed Jesse Lingard to seal the victory.
Wilfred Ndidi blasted over from a promising position after Nemanja Matic gave away the ball on the edge of his own box, with Leicester pressing United high in the early exchanges.
Kelechi Iheanacho should have done better when leading a three-on-two break but he scuffed a poor shot at De Gea rather than play a pass, with Jamie Vardy offside as he tried to pounce on the rebound.
Youri Tielemans placed a shot just wide before Marcus Rashford wasted United's best chance of the first half, blazing high and wide after Paul Pogba's bouncing ball had reached him.
United finally found some attacking rhythm in first-half stoppage time and only a good Schmeichel parry kept out Rashford's powerful half-volley.
A looping header from Vardy hit the top of the United crossbar as Brendan Rodgers brought on Ayoze Perez, knowing a goal was critical.
But when Hamza Choudhury lost possession to Mason Greenwood, Fernandes sent Martial through on goal and he was brought down by a combination of Wes Morgan and Evans, with Martin Atkinson awarding United a record 14th spot-kick in a single Premier League season.
Fernandes sent Schmeichel the wrong way to put United back into the Champions League for the first time since 2018-19.
Leicester's frustration boiled over in stoppage time when former United defender Evans was shown a red card for a tired lunge at substitute Scott McTominay, and Lingard made certain of matters when he tackled Schmeichel and slotted home his first league goal of the season in the 98th minute.
What does it mean? United complete unlikely comeback in top-four chase
With a 2-0 loss to Arsenal on January 1, United found themselves fifth, 14 points and 20 goals worse off than Leicester in second.
The fact they have finished the season above the Foxes - as well as Chelsea - highlights their improvement in 2020 and the problems Leicester have had with injuries and sustaining their form.
United are heading back to the Champions League then, but a Europa League spot and finishing above teams including Tottenham and Arsenal is not to be sniffed at for Leicester.
Maguire passes huge test on Leicester return
Booked after only nine minutes, Maguire generally marshalled the United defence well and cut out many attempted balls over the top for Vardy. He will be as thrilled as any United player to have snatched top four away from his old club.
Rashford needs a rest
Rashford missed a couple of openings in the first half and generally seemed off the pace, much as he has in the past two weeks. He looks like a player who will welcome a short break between now and the Europa League's return next month.
Key Opta Facts
- Manchester United recorded a top-four finish in the Premier League for just the second time in the past five seasons (also 2nd in 2017-18), while it is the third time they have managed to do so in the seven seasons since Alex Ferguson retired.
- Leicester City boss Brendan Rodgers has lost 10 of his 12 meetings with United across all competitions (W2), suffering defeats in each of the past five.
- United extended their unbeaten run to 14 games in the Premier League (W9 D5); their longest run without defeat in the competition since April 2017 (25 games).
- Since making his debut in the competition in February, Bruno Fernandes has been directly involved in more goals than any other player (15 - eight goals and seven assists).
- Jesse Lingard scored his first Premier League goal for United since December 2018, when he netted a brace in Ole Gunnar Solskjaer’s first game in charge against Cardiff City.
- Harry Maguire became the first outfield player since Gary Pallister in 1994-95 to start every game in a Premier League campaign for the Red Devils.
Leicester may be done for the season, but United's Europa League campaign resumes against LASK at Old Trafford on August 5.