Leinster's Brian O'Driscoll is tackled by Lionel Nallet of Castres
Castres (9) 18
Pens: Legardere (6)
Leinster (12) 15
Tries: Dempsey, Sexton
Leinster surrendered their 100% record in the Heineken Cup despite scoring the only two tries of their Pool Two encounter at Stade Pierre Antoine.
An early try from Girvan Dempsey gave the province an ideal start and a second touchdown by Johnny Sexton put them 12-9 up at half-time.
Replacement Felipe Contepomi's penalty extended the lead to 15-9.
But Anthony Legardere then added three penalties to his three in the first half to secure a first win for Castres.
The result is a huge blow to Leinster and came six days after they beat their French opponents 33-3 at the RDS.
They could have moved 11 points clear at the top of Pool Two with a bonus-point win.
However, lowly Castres, who are second-from-bottom in the French Championship, pulled off one of the shocks of this season's competition as Legardere kicked them to an inspiring win.
Man-of-the-match Legardere landed six out of seven penalty attempts, with his finalsuccess coming 10 minutes from time.
Dempsey's early try came after a defensive error in the Castres backline and Sexton kicked the extras.
Legardere then landed three penalties to put the home side 9-7 up.
But Castres then displayed midfield frailty to allow Sexton to round off a slick move after Luke Fitzgerald's half-break for a second try for the visitors.
Contepomi missed two kicks at goal immediately into the second half but converted his third attempt.
Legardere then brought Castres, down to 14 men with Steve Kefu yellow-carded, back to 15-15 with two well-struck penalties.
A sixth successful penalty from Legardere was enough to earn the French side their welcome win.
Leinster's defeat gives Wasps hope of closing the gap at the top of the group by beating Edinburgh on Sunday.
The Irish province travel to face the English champions at Twickenham in the next, potentially decisive, round of pool matches in January.
Castres: Bouquie, Sika, Kefu, Mazars, Christophers, Legardere, Tillous-Borde, Lensing, Giorgadze, Saayman, Tekori, Nallet, Tomiki, M. Masoe, Faure.
Replacements: Bonello, Ducalcon, Gaston, Koulemine, Senio, Sanchou, Bourret.
Leinster: Dempsey, S. Keogh, O'Driscoll, Fitzgerald, Kearney, Sexton, Whitaker, Healy, Jackman, Wright, Toner, O'Kelly, Elsom, Jennings, Heaslip.
Replacements: Blaney, McCormack, Hogan, O'Brien, Keane, Contepomi, Nacewa.
Referee: Dave Pearson (RFU),