Edinburgh secured a bonus-point win over a spirited Castres side to boost their hopes of Heineken Champions Cup progression.
Bill Mata's touchdown and a penalty try either side of Castres scores from Julien Blanc and Julien Dumora gave Edinburgh a 14-13 lead at the break.
Charlie Savala and Ben Vellacott tries took Edinburgh home, with Adrien Seguret replying for the visitors.
The win leaves Edinburgh in a strong position to reach the knockout stages.
While they opened their Champions Cup campaign with a defeat last weekend, there was enough in the performance away to Saracens to suggest Edinburgh can be competitive at this level.
The losing bonus point they secured also meant a win at home on Saturday would put them in a good position to progress from Pool A.
Stuart McInally was one of the standout performers against Saracens, but he departed injured in the opening minutes against Castres. Blair Kinghorn soon followed as Mike Blair was forced into some early rejigging of his team, having already lost Duhan van der Merwe just before kick-off.
The mood was lifted on the 20-minute mark when Mata blasted his way over the line to give Edinburgh the lead.
Castres made a host of changes from their home defeat by Exeter Chiefs in round one. What they did have was a small but vocal travelling support. They were given something to shout about when hooker Pierre Colonna gathered the loose ball from a messy line-out, made roadkill of Damien Hoyland and powered over in the corner.
Moments later the French side struck again. Edinburgh were caught out down the short side and Castres made the numbers pay, with scrum-half Blanc going over.
The home side needed a response and they got it when a rolling line-out maul was hauled down illegally as it headed for the Castres line. Penalty try.
Dumora's penalty for Castres ensured it was a one-point game at the break, a little too close for comfort from an Edinburgh perspective.
Their attack had largely failed to fire, that was until a slick backs move early in the second half sent Savala - on for the injured Kinghorn - through a gaping hole to score and give the scoreboard a healthier look at 21-13.
Vintage Champions Cup rugby this was not. There were turnovers, unforced errors and more spillages than one would find in an Edinburgh pub at Christmas as both sides struggled to impose any sustained pressure.
Edinburgh needed a try to kill it off and secure a bonus point, and it arrived 15 minutes from time.
A chip ahead from Hoyland bounced over the try-line, only for Castres wing Martin Laveau to make a complete hash of touching down, allowing Vellacott to show him how it's done.
Castres just would not go away, Seguret breaking through and stretching out to score, but Emiliano Boffelli's penalty ensured there would be no late turnaround.
Maximum points was what they came for and now Edinburgh can look forward with confidence to the festive double-header against old rivals Glasgow in the 1872 Cup.
Edinburgh head coach Mike Blair: "Castres put a lot of pressure on us and we did well to come out with the five points.
"Today was just one of those days when the ball just wasn't sticking. We could've had a couple of tries in the first half but the ball just didn't stick. That's frustrating but sometimes when you try to play rugby you've got to accept there will be errors in there and we still got the five points."
Edinburgh: Boffelli, Goosen, Currie, Lang, Van Der Merwe, Kinghorn, Vellacott, Schoeman, McInally, Nel, Young, Gilchrist, Ritchie, Crosbie, Mata.
Replacements: Dean for Currie (48), Savala for Kinghorn (13), Venter for Schoeman (62), Cruse for McInally (3), Williams for Nel (62), Sykes for Young (57), Muncaster for Crosbie (69). Not Used: Shiel.
Castres: Tries: Colonna, Blanc, Seguret. Cons: Botica. Pens: Dumora. Castres: Dumora, Laveau, Zeghdar, Seguret, Bouzerand, Botica, Blanc, Walcker, Colonna, Azar, Maravat, Hannoyer, Delaporte, Usarraga, Kornath.
Replacements: Larregain for Dumora (52), Kockott for Blanc (62), Humbert for Colonna (52), Guillamon for Azar (52), Vanverberghe for Maravat (52), Raisuqe for Usarraga (75), Guerois-Galisson for Kornath (37). Not Used: Cope. Sin Bin: Walcker (36).