Saints suffered late agony at The Rec as Rhys Priestland landed a penalty with the final kick of the game to earn a dramatic 32-30 win for Bath.
Priestland, who had missed another attempt just seconds earlier, stepped up to earn a priceless Aviva Premiership win for the fourth-placed side.
It left Saints shattered after they had produced a stunning second-half comeback from being 22-9 down.
Twice Stephen Myler had converted, from Api Ratuniyarawa and Jamie Gibson tries, to give Jim Mallinder's men the lead.
But Saints couldn't hold out and referee Wayne Barnes awarded a penalty to Bath, which Priestland slotted to draw a loud roar from the crowd at The Rec.
Both sides did their best to play at a high tempo in the early stages of the game, with Saints forced to hold out close to their own line before eventually winning a penalty at the scrum.
However, Saints were to lose the lineout, inviting more Bath pressure, and the away side eventually cracked, with No.8 Paul Grant finding a gap to score.
Fly-half Priestland missed the conversion and Saints reacted well, with some sharp inventive play from scrum-half Nic Groom bamboozling Bath into conceding a penalty.
Myler landed it from in front of the posts and he was soon repeating the trick after Bath again infringed.
Consequently, Saints led for the first time, but it didn't last long as their defence parted like the Red Sea and Semesa Rokoduguni strolled in for a score on his 100th Bath appearance.
Priestland added the extras to make it 12-6 and with Bath tails up, Ahsee Tuala had to be alert to hold up another attack at the last.
But it was only prolonging the inevitable as from the resulting scrum, referee Barnes awarded the home side a penalty try.
Priestland landed the conversion with ease and Bath had a healthy 19-6 lead with seven minutes of the first half to play.
Saints were starting to give themselves a mountain to climb, but Bath's discipline in defence remained questionable and they gave Myler another three points just before the break.
But Bath soon cancelled that out early in the second period as lovely play from Ben Tapuai turned up the heat and Barnes awarded a penalty, which Priestland kicked.
The next 10 minutes were nip and tuck, with Bath probing for another opening, but Saints standing tall.
And eventually the away side had something to shout about in the opposition half, with a relentless move ending with Myler fizzing a pass out to Ben Foden, who scored in the corner.
Myler converted superbly from the touchline and Saints were just six points behind with 20 minutes to play.
The men in white suddenly had confidence coursing through their veins, kicking to the corner in a bid to crank up the pressure on the home side.
And after Kane Palma-Newport was sin-binned, with Saints questioning whether they could have had a penalty try, Fijian lock Ratiuniyarawa bundled over for a big score.
Myler's conversion was equally as important, with the fly-half landing it with aplomb to give his team the lead.
But a moment of magic from Chris Cook quickly restored Bath's lead as the replacement scrum-half chipped ahead and dived on the ball to score.
Priestland converted to leave Saints, who felt there was a forward pass in the build-up to Cook's score, six points behind with eight minutes remaining.
But Saints were straight back at the Bath door, with the excellent Gibson grabbing a try in what was turning into a quite ridiculous second half.
Myler again needed nerves of steel for the conversion, and he kept his composure to put Saints 30-29 ahead with five minutes left.
But Bath wouldn't give up and after Priestland missed a tough kick from out wide, Saints failed to clear effectively and coughed up another penalty.
This time, Priestland made it, winning the match with the final kick.
Bath: Homer; Rokoduguni, Clark, Tapuai, Wilson (Davies 32 (Cook 69)); Priestland, Fotuali’i; Catt, Dunn (Batty 53), Lahiff (Palma-Newport 60); Stooke, Ewels; Ellis, Louw, Grant (60).
Saints: Tuala (Wilson 73); K Pisi, Tuitavake, Mallinder, Foden (c); Myler, Groom (Dickson 56); A Waller, Haywood, Brookes (Hill 64); Paterson (Ratuniyarawa (64), Day; Gibson, Harrison, Dickinson (Clark 56).
Referee: Wayne Barnes