Castleford (18) 40
Tries: McGoldrick, Shenton, Hudson, Dixon, Huby , Milner, Sargent
Goals: Westerman 6
Harlequins (6) 28
Tries: Howell, Sharp, O'Callaghan, Gale, Dorn
McGoldrick's try put Tigers on their way to victory
Castleford edged above Crusaders in the race for a Super League play-off place with a convincing win over Harlequins.
David Howell gave Quins an early lead before Ryan McGoldrick, Michael Shenton and Ryan Hudson put Tigers in control.
Kirk Dixon, Craig Huby, Adam Milner and Mitchell Sargent sealed the points for Cas after the break with Joe Westerman claiming six of seven attempts at goal.
Will Sharp, Jamie O'Callaghan, Luke Gale and Luke Dorn all crossed the line for Quins in the second half.
Castleford's victory means they lead Crusaders in the race for a top-eight finish on points difference.
Howell had put Quins ahead when he pounced on a loose ball which had looked as if it would go dead, but after Rob Purdham added the extras, Cas took control.
The hosts responded immediately, as McGoldrick latched onto Hudson's grubber kick to break through the Quins defence before Westerman's goal levelled the score.
Shenton then put Tigers ahead after Purdham was penalised for interfering before Hudson broke from dummy-half to secure an 18-6 half-time lead with Westerman converting both tries.
The hosts went further in front immediately after the break when Shenton set up Dixon in the corner.
Will Sharp pulled one back for the visitors following an impressive 60-metre run, but after Purdham again converted, Cas retaliated as Huby took advantage of a Louis McCarthy-Scarsbrook knock-on to power his way over on the first drive.
Milner added another for Cas as he fought off Oliver Wikes, Westerman converting both tries again, before O'Callaghan and Gale both crossed for Quins.
Sargent then added a final try for the hosts as Westerman claimed his sixth of seven attempts at goal before Dorn went under the sticks to claim a late consolation for Quins which was converted.
Castleford coach Terry Matterson:
"We've given ourselves a chance and that's all we could do today.
"We played pretty well in patches and looked the more dominant team, but credit to Harlequins they are never dead.
"They kept moving the ball around and they have some smart players. When they came back at us there, I wasn't worried, but you just never know.
"We won, we got the job done, and that's the nice thing."
Harlequins boss Brian McDermott said:
"I thought Castleford were better than us when they needed to be.
"They may have slackened off in the second half, either that or we raised our game, I'm not sure.
"I hope Terry Matterson is not too hard on his boys tomorrow, it's been a long season, and in essence they nailed the game when it needed nailing.
"We're not the smartest team every week but we certainly don't give in."
Castleford: McGoldrick, Dixon, Shenton, Ferres, Wainwright, Widders, Chase, Sargent, Hudson, Higgins, Snitch, Jones, Westerman.
Replacements: Arundel, Huby, Milner, Walker.
Harlequins RL: Melling, O'Callaghan, Clubb, Howell, Sharp, Gale, Dorn, Ward, Ellis, Wilkes, Purdham, Williamson, Golden, Mills.
Replacements: Mills, Orr, McCarthy-Scarsbrook, Bryan.
Ref: Phil Bentham (Warrington).