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 Kasper 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.
14 – Manchester United’s penalty at Leicester is their 14th Premier League spot-kick of the season, the most one side has ever won in a single campaign in the competition. Typical. pic.twitter.com/3yAuD9xHVp— OptaJoe (@OptaJoe) July 26, 2020
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.
Leicester may be done for the season, but United's Europa League campaign resumes against LASK at Old Trafford on August 5.
For in-depth, objective and more importantly balanced journalism, Click here to subscribe to Outlook Magazine