Leeds headed into Monday's (AEST) match needing to better Burnley's result because of an inferior goal difference and it was celebrating as news filtered through of Callum Wilson's first-half penalty for Newcastle.
Raphinha converted from the penalty spot at Brentford in the second half to further aid Leeds's cause, with Wilson doubling Newcastle's lead on the hour at Turf Moor after a pass from Allan Saint-Maximin.
However, Maxwel Cornet reduced the deficit for Burnley when he finished past Martin Dubravka and matters worsened significantly for Leeds when substitute Sergi Canos headed to level for Brentford.
But Canos was cautioned for celebrating by taking his shirt off and then dismissed soon after for a foul on Raphinha, with Brentford reduced to nine men after making all its substitutes when it lost Kristoffer Ajer to injury.
And Jack Harrison confirmed Leeds's Premier League status for next season as he smashed in after 94 minutes. It was the Whites' fourth stoppage-time winner in the Premier League. No team this season has scored more.
It meant Leeds became the first side since Wigan Athletic in the 2010-2011 Premier League season to head into the final day in the bottom three and survive, as Burnley joins Norwich City and Watford in the Championship next term.