Wakefield rode their luck to take their winning run against their neighbours to nine games and move into the play-off places.
Castleford were highly competitive but finished up with another defeat which keeps them at the foot of the table. Wakefield were second best for much of the first half but they led at the break thanks to some opportunism and a couple of doses of good fortune.
Cas led thanks to Ryan McGoldrick's kick and Luke Dorn's dive to get to the ball first, before Wakefield's first piece of luck. Danny Brough's kick bounced back off Awen Guttenbeil and gave him a clear run to the line.
The home side led again when McGoldrick spotted a gap, but then Dorn threw a speculative pass that was intercepted by Damian Blanch.
As half-time approached, the Tigers hammered away at the Wakefield line, only for Joe Westerman's knock-on to relieve the pressure. With seconds left in the half, Wakefield produced their most fluid rugby, Danny Sculthorpe and Tony Martin opening the way for Sean Gleeson and Matt Blaymire supporting on the inside to score Wakefield's third try. Brough converted again.
Martin was close to extending the lead early in the second half, from Sculthorpe's grubber. Cas also had to survive pressure exerted by Brough's 40-20 kick. Then they struck back, Dorn going over for his second try from McGoldrick's pass.
Trinity continued to have the best of the luck, however, and when Gleeson lost the ball in a tackle over the line it ran ahead for Rooney to touch down for a score which looked unsatisfactory but was allowed by the video referee.
Two minutes from time, Blanch distorted the scoreline further when he pounced on a loose pass for a second long-range try. It was a worse fate than Castleford deserved, but it looked as though losing to Wakefield has become a habit.