Wakefield, who had lost their four previous games, should have hung on after leading 12-6 at half-time and 20-12 midway through the second half, but inspired by captain Kallum Watkins, Leeds clawed their way to a precious 28-26 success,
Watkins scored a try in each half and booted four goals from five attempts, including an angled conversion which gave Rhinos a two-score advantage with three minutes left and was effectively the match-winner.
Trinity played well for much of the game and had an outstanding performer in forward Matty Ashurst, but they could not maintain their early pace.
Wakefield have got into the habit of fading in the second half, after leading at the interval and that again proved their Achilles heel.
Leeds scored first when Richie Myler grubbered between the posts and Watkins touched down at full-stretch before tagging on the conversion, after 16 minutes.
Trinity were level four minutes into the second quarter.
Jacob Miller had looked dangerous every time he got the ball and he opened the hosts’ scoring, stepping through from close to the line after Myler had made an outstanding tackle on Ashurst, but was penalised for holding down.
Ryan Hampshire, who did a good job filling in for the injured Liam Finn at scrum-half, added the extras and Trinity deservedly went ahead nine minutes before the break when Kyle Wood, who had just come on, threw a dummy and jinked over from acting-half.
Hampshire again converted to make it 12-6 at half-time, but Leeds – without stand-off Joel Moon due to illness – were level within seven minutes of the resumption. Wakefield’s defence had been strong up to that point, but they backed off a powerful run from Ash Handley and he touched down for his eighth try in five games.
Watkins’ conversion levelled the scores, but Trinity seemed to take control after that.
Hampshire booted a penalty for interference by Stevie Ward on Bill Tupou and at the end of the next set the scrum-half hoisted huge kick which bounced away from Ashton Golding and Ashurst backed up to gather and power over for a deserved try.
The conversion opened a two-score gap, but Wakefield lost their way as Carl Ablett – moving into a play-making role – and Watkins stepped up and Brad Dwyer made an impact off the bench.
Leeds pulled a try back with 18 minutes left, when Watkins finished strongly from Ablett’s pass after a fine run on the other flank by Handley.
That was unconverted, but Rhinos were in front three minutes later.
Golding was excellent at full-back and his run got them on the front foot before Myler flighted a lovely kick between the posts and prop Brad Singleton collected over the line to score a fine try which Watkins improved.
Leeds now led by two with 13 minutes left. They seemed to have sealed it in the 77th minute when Myler went close, then Watkins stabbed a kick through close to the line and Josh Walters did well to pick up and touch down for his second try in as many games.
Watkins’ goal – from a difficult angle – opened a two-score gap and that proved crucial as Leeds turned the ball over near their own line and Trinity’s young full-back Max Jowitt, who had a good game, pulled a try back.
Hampshire converted and in the final seconds Reece Lyne made a break, beating Handley and Ryan Hall, but Walters got back to drag him down, Trinity moved the ball left and Leeds’ defence numbered up to make the final tackle as the hooter sounded.
Wakefield Trinity: Jowitt, Jones-Bishop, Lyne, Tupou, Johnstone, Miller, Hampshire, Hirst, Randell, Huby. Ashurst, Batchelor, Horo. Subs Wood, Arona, Pauli, Kirmond.
Leeds Rhinos: Golding, Briscoe, Watkins, Handley, Hall, Sutcliffe, Myler, Jones-Buchanan, Parcell, Singleton, Ward, Walters, Ablett. Subs Dwyer, Ferres, Oledzki, Smith.
Referee: C Kendall (Huddersfield).