Former Swansea midfielder Hernandez left it late to keep Leed on course for automatic promotion.
The Spaniard netted in the 89th minute, controlling Luke Ayling’s cross to roll the ball home off a post.
It was a goal that moved Leeds three points clear of second-placed West Bromwich Albion and six ahead of third placed Brentford.
Marcelo Bielsa’s side need four points from their three remaining games to end a 16-year wait to return to the top-flight.
Swansea would have gone above local rivals Cardiff into sixth place if they had avoided defeat at the Liberty Stadium, but instead they remain outside the play-off spots.
Hernandez’s winner was a fitting end to a day when Leeds remembered the life of club great Jack Charlton, who made 773 appearances for them between 1953 and 1973.
The English 1966 World Cup winner clinched the old First Division title and the FA Cup with Leeds.
A minute’s silence was followed by warm applause from both sets of players and management staff, with Charlton’s image shown on the main scoreboard at the Liberty Stadium.
Leeds had not won in Swansea since April 1964, a 3-0 victory in which Charlton featured.
They were promoted into the top-flight as second tier champions that season and look odds-on to emulate that feat 56 years later.
Stoke eased their relegation worries with a comfortable 2-0 win over fellow strugglers Birmingham.
Danny Batth and Sam Clucas both scored during an impressive first half as the Potters climbed above Birmingham in the table.
It could have been an even more empathic half-time lead with Sam Vokes and James McClean both hitting the woodwork and Lee Camp pulling off a fine reflex save.
Stoke’s second successive home victory gives them a four-point gap to the relegation zone with three games left.
Download our app and read this and other great stories on the move. Available for Android and iOS.