Wakefield made the winning start they so desperately needed under their new coach, John Kear, although they insisted on doing it the hard way.
The dismissals of Monty Betham and Ned Catic, both for fighting, meant that the Wildcats played half the match with 12 men on the field and the final few minutes with only 11.
But they still finished strongly enough for three late tries to seal a victory that leaves them just two points behind Wigan in the battle to avoid relegation from Super League.
"We've put the cat among the pigeons and kept ourselves in touch with a clutch of other clubs,'' said Kear after seeing his new side end their losing run at five. "Now that we've won a game we can build some momentum.''
Wakefield, looking sharp and eager, made the ideal start, Ben Jeffries charging down Peter Lupton's kick inside the first two minutes and then directing the attack through the educated hands of David Solomona for Semi Tadulala to score in the corner.
Those proved to be the only points of a tense first half in which Castleford, despite being the more securely placed in the table, were often the more panic stricken side, wasting good field position with ragged handling.
Betham was held up over the line for Wakefield, while Castleford's best chance was negated by Solomona's fine cover tackle on Lupton.
A minute before half-time, the game erupted when Betham swung a series of punches at the prone Ryan McGoldrick, leaving the referee, Richard Silverwood, with little option but to send him off.
Wakefield lived dangerously from the start of the second half, with Adam Fletcher having a try disallowed for a forward pass and Gray Viane losing the ball on the line.
The video referee denied Ryan Atkins at the other end but Wakefield were to prove the more determined side. Their fierce defence kept Castleford at bay and then they rode their luck in the final 15 minutes.
Solomona's tackle forced a mistake from Andy Kain for vital possession and James Evans got away with a forward pass to put Colum Halpenny in at the corner for a vital try.
Four minutes later Evans, a late-season signing from Huddersfield, pulled Jamie Rooney's kick out of the air and scored, before Tom Saxton's arcing run put a final gloss on the scoreline.
With a minute to play, Catic was sent off for triggering the second major brawl of the game, but the points were safe with Wakefield, something that will cause Castleford, among other teams, to look nervously over their shoulders.
Castleford: Platt; A Fletcher, Shenton, Viane, Bird; McGoldrick, Lupton; Sculthorpe, Henderson, Nutley, Manu, Ward, R Fletcher. Substitutes used: Handforth, Kain, Huby, Fa'aoso.
Wakefield: Halpenny; Demetriou, Evans, Atkins, Tadulala; Rooney, Jeffries; Korkidas, March, Watene, Solomona, MacGillivray, Betham. Substitutes used: Obst, Elima, Catic, Saxton.
Referee: R Silverwood (Mirfield).Reuse content