Northampton gave themselves a shot at the Heineken Cup quarter-finals as they edged past Castres in tricky conditions to secure second place in Pool One.
Stephen Myler and Rory Kockott swapped penalties to make it 3-3 after an hour.
Myler's late penalty finally edged Saints back in front and George Pisi's converted try made the game safe.
Saints have 17 points but can be caught by Saracens, who play Connacht in Pool Three on Saturday and are favourites to take the final runners-up spot.
Mathematically Saracens are only one of four sides who can overhaul Northampton, but the Londoners are in pole position and will expect to be too strong for minnows Connacht, not withstanding the Irish province's famous win away to Toulouse earlier in the competition.
The six pool winners and two best runners-up go into the Heineken Cup quarter-finals, with the next three best runners-up entering the Amlin Challenge Cup - the likely destination for Northampton.
It was an error-ridden game dominated by defences that looked like being pointless at half-time until Myler finally broke the deadlock.
Castres pinned Saints back for much of the opening quarter and Northampton's inability to find a reliable replacement for the injured Ben Foden at full-back almost cost them as Fa'atoina Autagavaia endured a shaky first 40 minutes.
The visitors crossed the whitewash just after the half hour mark as Remi Grosso raced clear from a quick throw-in after George Pisi had sliced a kick into touch, but the French side had not used the same ball and the score was rightly disallowed.
As the half wore on Saints got on top and right on the stroke of half-time a Castres infringement gave Myler a simple shot at goal to finally open the scoring.
With defences having the upper hand there were few chances but soon after the interval a searing break through midfield from Marcel Garvey, the former Gloucester winger now playing for Castres, reminded English audiences of just what an electric runner he is.
But the wing, with support inside, slipped as he tried to beat the last man and the chance went begging.
The near incessant rain in England over the winter had reduced the normally pristine playing surface at Franklin's Gardens to a heavy bog and the pitch would again play a part when Saints won an attacking line-out.
The hosts launched a driving maul and then spun the ball wide but England squad member Luther Burrell slipped five metres out when he tried to step inside and the Castres defence swooped to win a penalty as the Northampton centre held on in desperation.
A few minutes later Kockott won a penalty at a ruck in similar fashion inside the Saints half and the replacement scrum-half drilled over the kick himself to level the scores.
Inside the final 10 minutes the South African thought he had put Castres in front after Saints lock Courtney Lawes, who had a fine game otherwise, was penalised for holding on just inside his own half.
Kockott gave his penalty kick a real thump off the unhelpful surface but it landed inches short.
It was the let-off Northampton needed and clever play from replacement nine Kahn Fotuali'i earned Myler the chance to kick them back into a narrow lead.
Northampton faced a nervous couple of minutes to survive but with 80 minutes on the clock George Pisi charged down Kockott and dived joyously over for a converted try to keep Saints - just - alive.
VIEW FROM THE DRESSING ROOM
Northampton director of rugby Jim Mallinder:
"They are the French champions and they proved it tonight. Their defence was very good, their line speed cut down our options, stopped us getting on the front foot and getting any momentum.
"We will also look at the game down at Castres and think that was a big opportunity we missed. When you are up against good sides like that, you have really got to take your opportunities."
Northampton: Autagavaia; K Pisi, G Pisi, Burrell, North; Myler, L Dickson; A Waller, Hartley, Ma'afu, Lawes, Day, Clark, Wood, Manoa.
Replacements: G Dickson for Autagavaia (68), Waldouck for Burrell (63), Fotuali'i for L Dickson (55), E Waller for A Waller (60), Haywood for Hartley (60), Denman for Ma'afu (51), Dowson for Clark (54), Dickinson for Manoa (60).
Castres: Dulin; Garvey, Cabannes, Lamerat, Grosso; Kirkpatrick, Tomas; Forestier, Rallier, Peikrishvili, Samson, Gray, Babillot, Bornman, Faasalele.
Replacements: Lakafia for Garvey (67), Bonnefond for Lamerat (62), Kockott for Tomas (51), Taumoepeau for Forestier (51), Lazar for Peikrishvili (27), Desroche for Babillot (64), Caballero for Faasalele (41).
Not Used: Coetzee.
Ref: Alain Rolland (Ireland).