Leinster suffered a Heineken Cup hiccup in the south of France as ice-cool Castres prevailed in freezing conditions at Stade Pierre Antoine.
The Irish province could have moved 11 points clear at the top of Pool 2 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 Anthony Lagardere kicked them to an inspiring win.
Man-of-the-match Lagardere landed six out of seven penalty attempts, with his sixth and most important success coming 10 minutes from time.
Rudderless for most of the night and struggling at the breakdown, Leinster simply ran out of time as their winning run in Europe came to a disappointing end.
They did muster first half tries from Girvan Dempsey and Jonathan Sexton but despite enjoying a 15-versus-14 advantage when Castres centre Steve Kefu was sin-binned, Michael Cheika's men were outfought.
Former captain Brian O'Driscoll gave Leinster a pre-match boost by passing a fitness test on a hamstring strain, although World Cup-winning prop CJ Van Der Linde was forced out with a calf injury.
Castres, who made eight changes to the team that lost 33-3 in Dublin last weekend, have been under a cloud domestically and in Europe this season - winning only three of their 15 matches before tonight's clash.
This week's announcement that Laurent Travers and Laurent Labit will assume control at Stade Pierre Antoine for the next three seasons was hardly music to the ears of Alain Gaillard and his coaching staff.
Castres' morale certainly came into question in the pre-match build-up and they got off to a nightmare start when Dempsey stole in for a fifth-minute try.
Charles Sika spilled an O'Driscoll kick close to his line and Dempsey deftly swooped on the loose ball to score. Jonathan Sexton added a superb conversion from the touchline.
But the Leinster number 10 missed a much easier effort moments later and with Florian Faure, Chris Masoe and fit-again captain Lionel Nallet assuming control, the home side gradually got themselves into the game.
Lagardere's well-struck opening penalty bounced through off the left upright and Castres cut the gap to 7-6 when a Joe Tekori-inspired counter-attack saw Leinster infringe once again.
The Irish side never built on that early promise and after a Rob Kearney knock-on, a wheeled scrum and an offside call, Lagardere sent over his third penalty success.
Stung into action, Leinster snuck back ahead in the 29th minute with a well-executed attack.
Luke Fitzgerald punctured the hosts' midfield and strong carries from Jamie Heaslip, Shane Jennings and Simon Keogh helped Sexton crash over.
The try went unconverted and Leinster weathered a late storm from Castres, which included a bout of scrum pressure and a missed Lagardere penalty, to lead 12-9 at the break.
Felipe Contepomi, who had recovered from a hand infection to play, began his second-half introduction with two missed penalties and Leinster continued to lack ideas in attack.
The harsh sin-binning of Kefu for killing the ball close to the posts gave the visitors an ideal chance to steady themselves and Contepomi duly kicked them into a 15-9 lead.
Nevertheless, with plenty of hard hits and commitment from the fourth-placed Frenchmen, Leinster lost their discipline and shape as Castres turned the tide.
They forced a series of penalties which Lagardere impressively dispatched, after 60, 65 and 70 minutes.
Posting their first European win since last January, Castres defended manfully in the closing stages and a brilliant steal on the deck from Masoe put the final nail in Leinster's coffin.