Match ends, Brentford 1, Leeds United 2.
Leeds United manager Jesse Marsch said it took everything he had to keep the Elland Road club in the Premier League.
Marsch replaced much-loved Marcelo Bielsa as Leeds boss with 12 games of a troubled campaign remaining and achieved his aim of avoiding relegation with a last-day victory at Brentford.
Jack Harrison's added-time winner removed any lingering doubts over survival, sparking scenes of celebration on the pitch, in the stands and the technical area, where the American manager lay on his back in jubilation.
"I knew it was going to require all of my being when I came here and that proved to be true," Marsch told BBC Sport.
"I heard a lot about Leeds United doing it hard way. Part of my job is to change that mentality to say we deserve more. We are an incredible club with an incredible team. We think we deserve what we have got."
Marsch said he could offer no guarantees about the future of any of his players, including England midfielder Kalvin Phillips and Brazil winger Raphinha, who opened the scoring with a well-taken second-half penalty.
He intends to speak with the Leeds hierarchy in the next couple of days to plot a way forward.
"There wasn't one day I didn't believe," said Marsch. "I never talked about being in the Championship."
Leeds started the day needing to better Burnley's result to survive.
When Sergi Canos levelled for a Brentford side that had already been reduced to 10 men and would be down to nine shortly afterwards when the goalscorer received his second yellow card, Marsch told some of his backroom team to stop watching Leeds and concentrate on events at Turf Moor.
"I told some my coaching staff just to watch the match because I didn't need any more help with our own team," he said.
"We tried to communicate that. We wanted to win the game and end it so Burnley couldn't have a lucky punch to seal our fate."
Leeds escape on memorable day
The result meant Leeds became the first side since Wigan in 2011 to survive after starting the final day in the bottom three.
Although the Leeds players and staff were booed by the Brentford fans for the duration of their celebrations after the final whistle, which delayed the home side's planned lap of honour, their euphoria was hardly surprising.
With just two points from their last five games, the sense of trepidation among Leeds fans on their journey south was understandable.
If a reminder was needed of how uncertain the final day could be, it came in a two-minute period midway through the opening half.
News of Newcastle's penalty award at Turf Moor was filtering into the visiting section, which was starting to crackle with excited noise, when Joe Gelhardt buried a shot into the Brentford net.
The reaction of referee Paul Tierney suggested he felt the goal would not stand and VAR duly ruled it out for offside. At almost exactly the same time, Newcastle converted their spot-kick.
Even after Raphinha had kept his nerve to find the net after he had been chopped down by Brentford keeper David Raya, Leeds fan still did not allow themselves to believe the escape act was on.
Canos duly brought them down to earth with his equaliser but he was booked for his celebration and then followed that up by fouling Raphinha, which wrecked Brentford's chances of turning the game around.
Leeds' safety was ensured when Harrison drilled home the winner and, to their credit, Leeds' fans remained in the stands as they sang their songs of survival.
Brentford's excellent debut season
Brentford's first season in the Premier League has been superb.
They might have missed out on a top-half finish but, as was pointed out on numerous occasions by the stadium announcer, not once have they been in the bottom three.
With a bit more composure - and a full compliment of players - they might have got something out of this game.
Bryan Mbeumo wasted their best two chances either side of the break and Christian Eriksen couldn't quite find his passing range.
Brentford will carry on trying to persuade Eriksen to stay with them, while manager Thomas Frank will set himself the target of avoiding the kind of second season problems Leeds have only just managed to overcome.
- 1RayaBooked at 55mins
- 20AjerSubstituted forat 76'minutes
- 29Bech SørensenSubstituted forBaptisteat 70'minutes
- 3HenrySubstituted forCanósat 63'minutesBooked at 80mins
- 8JensenSubstituted forDasilvaat 58'minutes
- 17ToneyBooked at 78mins
- 42GreenwoodSubstituted forKlichat 85'minutes
- 23PhillipsBooked at 82mins
- 30GelhardtSubstituted forStruijkat 71'minutes
- Paul Tierney
- Shots on Target
Second Half ends, Brentford 1, Leeds United 2.
Goal! Brentford 1, Leeds United 2. Jack Harrison (Leeds United) left footed shot from outside the box to the bottom left corner following a corner.
Corner, Leeds United. Conceded by Yoane Wissa.
Attempt blocked. Jack Harrison (Leeds United) right footed shot from the centre of the box is blocked. Assisted by Pascal Struijk.
Attempt saved. Raphinha (Leeds United) left footed shot from outside the box is saved in the centre of the goal. Assisted by Kalvin Phillips.
Shandon Baptiste (Brentford) wins a free kick in the defensive half.
Foul by Jack Harrison (Leeds United).
Attempt missed. Raphinha (Leeds United) left footed shot from the right side of the box is too high.
Attempt saved. Mateusz Klich (Leeds United) left footed shot from outside the box is saved in the top left corner. Assisted by Rodrigo.
Attempt missed. Mateusz Klich (Leeds United) right footed shot from outside the box misses to the right.
Substitution, Leeds United. Mateusz Klich replaces Sam Greenwood.
Attempt missed. Ivan Toney (Brentford) header from the centre of the box is close, but misses to the left. Assisted by Christian Eriksen following a set piece situation.
Ivan Toney (Brentford) wins a free kick on the right wing.
Foul by Pascal Struijk (Leeds United).
Kalvin Phillips (Leeds United) is shown the yellow card for a bad foul.
Bryan Mbeumo (Brentford) wins a free kick on the right wing.
Foul by Kalvin Phillips (Leeds United).
Corner, Leeds United. Conceded by Bryan Mbeumo.
Attempt blocked. Raphinha (Leeds United) right footed shot from outside the box is blocked.
- Our coverage of your Premier League club is bigger and better than ever before - here's everything you need to know to make sure you never miss a moment