Ulster clinched a first Heineken Cup victory on French soil here yesterday to guarantee home advantage in the quarter-finals of the competition.
Although not at their best in a scrappy affair, the visitors finished the stronger of the two sides and claimed the points courtesy of three penalties from Ruan Pienaar.
Castres had led early on thanks to a well-worked try from Rémi Lamerat but failed to build on their supremacy against the Pool Four winners, who rallied after half-time.
Ulster, made six changes to the team that beat Glasgow 23-6 at Ravenhill last Friday, while Castres also made significant alterations, including an entire new back row.
Last season's finalists made a strong start to the game, but it was first blood to Castres, after some fantastic work by Scotland's Max Evans. The 29-year-old managed to keep the ball in play as he was tackled on the wing and off-loaded to Piula Faasalele who, in turn, passed inside to Lamerat for the centre to finish in style.
Shortly after the restart, Castres' Mathieu Babillot was penalised at the breakdown and Pienaar – who has stated he wants to sign a new contract with the club – made no mistake to register Ulster's first points of the match.
Castres continued to press, however, and were awarded a penalty of their own when Paddy Wallace was penalised for a swinging arm.
Unlike with his failed conversion attempt, Rory Kockott made no mistake with the penalty to give Castres an 8-3 lead. Top spot and qualification to the quarter-finals was already assured for Ulster but they knew that only a win would guarantee a home tie in the last eight.
Although the Ulstermen were sloppy for the majority of the first half, a penalty for obstruction four minutes from the break gave Pienaar a chance to reduce the gap which he gratefully accepted.
The fly-off was less clinical with another penalty opportunity following a scrum infringement, leaving the half-time score 8-6 to Castres.
After an uneventful opening 10 minutes to the second period, the hosts were awarded a penalty inside their own half and Kockott made the ambitious decision to go for the posts. His mighty kick had the length but not the direction and the miss was to prove costly.
Mark Anscombe, the Ulster coach, introduced Paddy Jackson, the replacement scrum-half, close to the hour mark in the hope of giving his team some much-needed spark.
Ulster then started to improve and when a penalty was awarded in front of the posts after Mihaita Lazar was punished for being offside, Pienaar kicked it to edge Ulster ahead for the first time.
The visitors seemed to be buoyed by Pienaar's kick and started to enjoy a much healthier share of the ball as they controlled the remainder of the game.
Anscombe admitted afterwards that his team struggled in the early part of the encounter. "We were very flat in the first half, we kept giving the ball away and couldn't get our lineout going," he said.
"It wasn't pretty. They are the sort of side that don't make it easy for you, but the character of the guys saw us through in the end.
"It was good to tick that box and get that first win in France in the Heineken Cup.
"I said at half-time that if we get the ball and play some rugby, opportunities would come.
"We could not come here and expect to score four tries, but there were opportunities and holes in Castres. We just needed to take a bit more care with the ball."
Castres P Bernard; M Evans, S Baikeinuku (M Andreu, 51), R Lamerat (P Bonnefond, 62), M Garvey; R Tales, R Kockott (T Lacrampe, 55); Y Forestier (S Taumoepeau, 45), M Rallier (B Mach, 61), A Peikrishvili (M Lazar, 53), M Rolland (capt; I Tekori, 70), C Samson; M Babillot (J Bornman, 55), P Faasalele, P Wannenburg.
Ulster C Gilroy; A Trimble, D Cave, P Wallace, M Allen; R Pienaar, P Marshall (P Jackson, 55); T Court, R Best, J Afoa, L Stevenson, N McComb, R Diack, C Henry (capt), R Wilson (I Henderson, 28).
Referee N Owens (Wales).
Pens: Pienaar 3