Danny McGuire became the leading try scorer in Super League history as champions Leeds beat Wakefield to reach next weekend's preliminary semi-finals.
Trinity twice led through Ben Cockayne and Leeds old boy Lee Smith, only for two converted efforts from Rob Burrow to give Leeds a 12-10 half-time lead.
Richie Mathers, one of three ex-Rhinos to score, put Trinity ahead again.
But Ben Jones-Bishop (3), the fit-again McGuire, with his 200th try in Super League, and Zak Hardaker wrapped it up.
Kevin Sinfield kicked all seven conversions as Leeds booked a trip to Perpignan to face Catalan Dragons next Friday night.
But battling Wakefield, who went into the game on the back of a club record run of seven straight wins, were left to rue two match-turning moments.
The first came just before the interval when they had a great chance to go 16-6 up, but blew it, only for Kallum Watkins, creator of Burrow's first try, to again set up the dimunitive hooker to break away and score.
Then, having got back in touch at 30-20 thanks to a try from Ali Lauitiiti - the third of Wakefield's three try-scoring Leeds old boys - they wasted a golden chance to get within four points.
With 10 minutes left, Cockayne spilled Danny Washbrook's loose pass just when he looked set to go in under the posts. And the Rhinos rubbed their noses in it by going up the other end to add two more tie-clinching late tries through Hardaker and Jones-Bishop - his hat-trick try.
Leeds had trailed for the third time in the match early in the second half at 16-12, after Mathers' try, but winger Jones-Bishop collected a brilliant kick from Kevin Sinfield to put his side back in front with his first try.
Then came McGuire's 60th minute try from a break by man of the match Burrow.
The 29-year-old Rhinos favourite equalled former Leeds team-mate Keith Senior's record of 199 tries before picking up a knee injury against Widnes last month.
But, after a frustrating month sidelined with an untimely knee injury that cost him a place in the Challenge Cup final, McGuire returned to complete his double century - on his 257th Super League appearance.
VIEW FROM THE DRESSING ROOM
Leeds stand-off Danny McGuire:
"It's a really special moment. It's an honour to be the top try-scorer in Super League. Hopefully there's plenty more in me and more in me for this season.
"It was a tough one. Wakefield brought their full package tonight. They didn't die wondering.
"They pushed us and we had to find out a little bit about ourselves during that first half. The scoreline probably is a bit flattering but it's pleasing to have stayed strong."
Wakefield coach Richard Agar:
"Energy got us. Our effort was not in question. We knew we needed to be really good tonight. We just didn't quite execute to the level that we needed to.
"I thought the game was summed up when Danny Washbrook had a chance to make it a four-point ball game. I don't think anybody would have backed against us at that point having another crack at their line, but we didn't execute and they ran the length of the field.
"I've some troops in that dressing room who have come to Headingley to play the champions in a play-off game and are genuinely disappointed that they've not won and know exactly the reasons for it. That to me is progress. It's an indication of how far we've come in the last 12 months."
SATURDAY NIGHT'S LINE-UPS
Leeds: Hardaker; Jones-Bishop, Watkins, Ablett, Hall; Sinfield, McGuire; Leuluai, Burrow, Peacock, Jones-Buchanan, Delaney, Bailey.
Replacements: Clarkson, Ward, Lunt, Griffin.
Wakefield: Mathers; Fox, Collis, L Smith, Cockayne; Sykes, T Smith; Amor, Ellis, Raleigh, Lauitiiti, Kirmond, Washbrook.
Replacements: Mariano, Wilkes, Wood, Johnson.
Referee: Steve Ganson (England).