Wakefield 12 (8)
Tries: D March, T Saxton
Goal: Rooney
Leeds 14 (12)
Tries: Tansey, Diskin
Goals: Sinfield 3
Leeds ended a morale-sapping run of five straight defeats with a tense victory at Belle Vue which leaves Wakefield deep in the relegation mire.
The Rhinos led 12-8 at the break via a first-minute try from Jordan Tansey and a second from Matt Diskin followed David March's effort for the hosts.
But the Wildcats levelled with a superb try from Tom Saxton on the resumption before tempers started to fray.
Kevin Sinfield's penalty just before the hour proved the winning score.
Scott Donald had a further try ruled out after Jamie Jones-Buchanan was penalised for foul play after a mix-up between Colum Halpenny and Semi Tadulala in the Wildcats' backline.
Trinity launched a last-ditch rescue act but the Rhinos finished the stronger and held on for a victory which consolidates their third place.
Wakefield's first defeat under new coach John Kear, after two straight wins, leaves them precariously placed in the dogfight at the bottom.
They are a point adrift of Castleford - who they face on the final day of the regular season - and two behind Wigan and Huddersfield, but their next two games are away to leaders St Helens and champions Bradford.
Wakefield coach John Kear:
"We gave an outstanding performance and there's no way that we looked like a relegation-threatened team. "That looked like a play-off game and the performance was exceptional. I'm very proud of the players' hard work and we're learning that when we prepare very well, we play very well.
"We got two wins before this game but tonight it's just gone against us and even though we played well, I'm obviously bitterly disappointed we lost."
Leeds coach Tony Smith:
"We had to graft really hard. It was a hard-fought game between two desperate teams, for different reasons. "We were playing for a lot of pride and they are playing for their lives. We had to guts it out, and the way we defended our own line was outstanding.
"It got a little messy towards the end but the main thing is we won. I thought Matt Diskin was outstanding and he's certainly one player who will draw confidence from this game."
Wakefield: Saxton, Halpenny, Demetriou, Atkins, Tadulala, Rooney, Jeffries, Korkidas, March, Watene, MacGillivray, Henderson, Solomona.
Replacements: White, Elima, Obst, Griffin.
Leeds: Tansey, Donald, Toopi, Senior, Gibson, Sinfield, Burrow, Jones-Buchanan, Diskin, Thackray, Lauitiiti, Peacock, Ellis.
Replacements: Bailey, Poching, Scruton, Kirke.
Referee: Phil Bentham (Castleford)