Harlequins withstood a late fightback to end Castres' unbeaten European home run and earn a narrow victory in their Heineken Champions Cup opener.
Martin Laveau's converted try reduced the deficit to two points with four minutes to play.
The hosts took the lead through Josaia Raisuqe before Louis Lynagh crossed for the English champions.
Alex Dombrandt's try handed Quins the lead and Marcus Smith's penalty put them out of reach despite Laveau's try.
Castres had not lost at home this year, while their impressive unbeaten European run at the Stade Pierre Fabre had stood since January 2015 - when they last lost to Quins.
The hosts got off to a positive start when Filipo Nakosi danced through the Quins defence to feed Raisuqe for a simple run in.
The English champions nudged in front when Danny Care showed brilliant awareness to flick the ball on to Lynagh for their opening try.
Benjamin Urdapilleta's two penalties saw Castres edge in front before the interval but Quins hit back after the break when Dombrandt burst through the host's defence to score his side's second try.
Smith's conversion was followed by the England fly-half's penalty to extend their lead to nine points, but Castres hit back almost from the kick-off as the ball was moved to Laveau, who did the rest.
The Top 14 side regained possession from the restart and ventured deep into the Quins half as Urdapilleta stepped back in anticipation of an attempt at the drop goal.
With the ball set, Castres decided to opt for another phase before what surely would have been the pass to their fly-half, but they were penalised for sealing off at the breakdown.
Quins, who last reached the knock-out stages of Europe's premier club competition in 2013, will host Cardiff Blues in their next game on Saturday, 18 December.
Castres: Larregain; Laveau, Combezou, Aguillon. Nakosi; Urdapilleta, Kockott; Tichit, Ngauamo, Guillamon, Hannoyer, Whetton, De Crespigny, Raisuge, Ben-Nicholas
Replacements: Humbert, Nostadt, Tierney, Staniforth, Ardron, Meka, Arata, Le Brun
Harlequins: Green; Lynagh, Jones, Esterhuizen, Murley; Smith, Care; Marler, Walker, Collier, Tizard, Lewies (capt), Chisholm, Lawday, Dombrandt
Replacements: Musk, Garcia Botta, Kerrod, Hammond, Kenningham, Gjaltema, Edwards, Beard