And eighth-placed United are still in the hunt for that place after beating Newcastle to move level on points with the seventh-placed Magpies.
Goals from Kobbie Mainoo, Diallo and Rasmus Hojlund at Old Trafford gave United only their third win in nine league games.
However, United’s goal difference is vastly inferior to Newcastle’s, meaning they must better the Magpies’ result in the last game of the season.
United travel to Brighton on Sunday, while Newcastle head to Brentford.
Newcastle’s defeat means fifth-placed Tottenham are guaranteed to be in the Europa League next season.
Sixth placed Chelsea won 2-1 at Brighton in Wednesday’s other game to move closer to European qualification after a turbulent campaign.
United embarked on a sheepish ‘lap of honour’ after their final home game of the season.
And, while it has hardly been a campaign to celebrate, this was a much-needed result as Ten Hag fights to avoid the sack at the end of a season that ranks as one of United’s worst in the Premier League era.
“It’s important to win the last game at Old Trafford this season. The fans deserve this because they’ve had difficult times and always stayed with us,” Ten Hag said.
“We wanted to pay the fans back. We have Brighton in the last game which is important in the ranking. We don’t have it in our hands but we have to do our job.”
United’s first half dominance was rewarded in the 31st minute when Diallo’s deflected pass found Mainoo completely unmarked thanks to Kieran Trippier’s sloppy marking.
The teenage midfielder looked shocked he had so much time and space as he picked his spot with a low finish from 12 yards.
Newcastle drew level in the 49th minute as Anthony Gordon was given the freedom of the penalty area to convert Jacob Murphy’s cross with a close-range volley.
Ten Hag’s angst was short-lived as United regained the advantage in the 57th minute when Newcastle could only clear Bruno Fernandes’ corner to Diallo, who lashed a fierce shot past Martin Dubravka from just inside the area.
Hojlund came off the bench to net in the 84th minute with a lethal finish after evading two defenders, but Lewis Hall’s stoppage-time curler from long-range kept United sweating until the end.
© Agence France-Presse
Photo: Twitter @UnitedsUpdates