Fiji centre Verimi Vakatawa scored a try three minutes from time to help Racing Metro end Castres' seven-match winning run with a 23-19 Top 14 win on Friday.
Castres, who led 19-13 at one stage in the second half, still went top of the table courtesy of their losing bonus point, but they could be deposed on Saturday when Clemront take on bottom-of-the-log Biarritz.
Vakatawa's 77th-minute try was converted by full-back Gaetan Germain as Racing ended their three-match losing run.
The sides had been locked at 13-13 at the interval with Racing fly-half Sebastien Descon crossing in the 21st minute before Castres lock and skipper Chris Masoe replied four minutes later.
Romain Teulet, who missed Castres' last two games, kicked his side's other 14 points.