Form team Catalans Dragons were pushed all the way by Super League's bottom club Castleford before extending their club record unbeaten run to eight matches.
The Dragons, who discovered this week they will lose popular coach Mick Potter to St Helens at the end of the season, completed the double over the Tigers in front of another bumper crowd of 8,745 at the Gilbert Brutus Stadium.
But Castleford belied their position in the table with a gutsy display, twice taking the lead in the first half and then fighting back from 32-18 down to set up a tense finish.
When winger Adam Fletcher scored the Tigers' fifth try four minutes from the end and Kirk Dixon kicked a fifth goal, the Catalans lead was down to just two points and they needed a last-minute score from French Test loose forward Gregory Mounis to clinch victory.
Full-back Clint Greenshields and hooker Aaron Gorrell both touched down on their return to the Dragons side while ex-Wakefield and Salford prop Michael Korkidas scored his first try for Castleford.
Dimitri Pelo, restored to his customary wing spot after a run-out at full-back in last week's Challenge Cup win at Featherstone, opened the scoring after only two minutes with his sixth try of the season and Thomas Bosc kicked the first of five goals.
Prop Jerome Guisset also touched down but converted tries from centre Michael Shenton and loose forward Joe Westerman gave the visitors a 12-10 lead after 22 minutes.
When centre Sebastien Raguin, Gorrell and winger Justin Murphy all touched down in a seven-minute spell, the home side appeared to be coasting at 24-12.
Korkidas pulled a try back for Castleford but Greenshields touched down on the stroke of half-time and Bosc landed a penalty on 50 minutes to extend his side's lead to 32-18.
The Dragons, who had Raguin sin-binned seven minutes into the second half, conceded further tries to stand-off Ryan McGoldrick and Fletcher to put their lead at risk but Mounis came to their rescue with his late try.