Salford held off a tremendous fightback from Wakefield to secure a 28-20 success and end the Super League season with a third successive win.
The Challenge Cup runners-up played some delightful rugby to establish a 22-4 half-time lead at Headingley but Trinity stung them with three tries in 16 minutes, two of them from forward Kelepi Tanginoa, to set up a nerve-jangling finish.
Back-row forward Tyrone McCarthy then made sure his team-mate Mark Flanagan would end his career on a winning note when he grabbed the clinching try nine minutes from the end.
It was also a fitting way for England centre Kallum Watkins to mark the 300th match of his career on the ground where he made his name as Salford climbed above their opponents to finish the year in ninth place in the table.
The game was a dead-rubber after a decision in the build-up to dock the Red Devils three wins for a breach of insolvency regulations killed off any lingering hopes of them making the extended play-offs but there was no shortage of commitment from either team.
Wakefield suffered a body blow before kick-off, losing captain Jacob Miller with an ankle stress fracture, while the Red Devils were also forced into a late change after Dan Sarginson pulled out in the warm-up with an injured glute.
But Salford had a ready-made full-back replacement in Niall Evalds, who came in for his last match for the club as he prepares to make the move to Castleford, and his pass got winger Krisnan Inu over for the opening try.
Inu, who has scored five tries in the last three matches, then unselfishly returned the favour, sending Evalds in for a try after Tui Lolohea’s cut-out pass had created the opening and Inu’s goal made it 10-0.
Wakefield were unfortunate to have a try from winger Ben Jones-Bishop disallowed for offside and they suffered another blow when loose forward Jay Pitts was forced off with an arm injury.
It got worse for them when Salford centre Ed Chamberlain pounced on a loose ball, hacked it ahead and re-gathered to go in from 60 metres for an opportunist try that extended his side’s lead to 16-0.
Trinity pulled a try back in the 30th minute through full-back Ryan Hampshire, who supported a break by centre Reece Lyne, but they fell further behind three minutes before half-time when hooker Andy Ackers broke clear and Lolohea was in support to score Salford’s fourth try.
Inu’s third goal made it 22-4, which was the half-time score, and Inu had a second try disallowed early in the second half before Trinity began their fightback with a first effort from Tanginoa, who won the chase to Brad Walker’s grubber kick.
Hamphire’s first conversion cut the gap to 12 points and he reduced it further on the hour when he put winger Innes Senior into space and was on hand to take a return pass to score his second try.
The momentum was firmly with Wakefield by then and the sin-binning of Salford prop Lee Mossop for a trip on hooker Kyle Wood enabled them to keep the pressure on.
It paid off when Walker got Tanginoa over for his second try and Hampshire’s second goal put just two points between the sides but that was as good as it got for Wakefield.
A grubber kick from Lolohea was fumbled over his own line by Senior and gifted a try to McCarthy, to which Inu added his fourth goal.