The black, green and gold were in the game until the final seconds before a Josh Bayliss breakaway try sealed the win for Bath, who booked their Champions Cup spot for next season in the process.
Saints had already secured theirs, having guaranteed a fifth-place finish following their narrow defeat to Exeter Chiefs on the previous weekend.
But Chris Boyd's side showed no signs of slacking off on the final day, giving it everything they had to end the season in style.
It looked like they may do just that when James Grayson grabbed their bonus-point try in the second half, adding to three first-half efforts, from Taqele Naiyaravoro (2) and Rory Hutchinson.
But Bath battled back through the boot of Rhys Priestland, and Bayliss put the seal on the win, bringing the home fans to their feet with an eye-catching score.
Saints had gone into the game having lost a couple of players just before kick-off as Nick Auterac and Matt Proctor were ruled out.
The away side won a couple of penalties inside their own half early on at The Rec, but after losing a lineout in Bath territory, they found themselves in trouble.
Lewis Ludlam was smashed in the tackle by two home players, who earned their team a penalty, which Priestland kicked.
Ludlam then spilled a poor pass close to halfway, allowing Bath to fly forward, but Tommy Freeman turned on the turbos and got back to stop the home side scoring.
The game was really struggling to catch fire as both sides made basic errors, with Saints having a tough time securing possession on their own lineout ball.
But a scruffy start was put to bed when Saints pieced together a lovely move which ended with Courtney Lawes coming into the attack brilliantly and releasing Naiyaravoro for the score.
Grayson converted but Bath responded almost immediately as Sam Underhill charged down Alex Mitchell's attempted clearance and ran on to the ball to ground it.
Priestland failed with the conversion to leave the Bath lead at a single point with 24 minutes played.
But Saints were soon further behind as Anthony Watson superbly sidestepped Freeman before sending Taulupe Faletau in for the try.
Priestland converted to make it 15-7 before Grayson attempted a long-range penalty, which went wide of the left post.
Saints then had a huge let-off as Watson dropped the ball in the act of trying to score what looked likely to be a routine try in the corner.
And how Bath were made to pay.
First, Naiyaravoro did some fantastic work to set Hutchinson free, and the centre made the most of his chance in devastating fashion, rounding his man before scoring acrobatically in the corner.
Grayson converted and Bath's lead was down to just a point.
Saints still had more petrol in the first-half tank, too, piecing together an incredibly patient move that ended with Naiyaravoro scoring in the corner.
Grayson missed the conversion with the final kick of the half but Saints would go in 19-15 ahead thanks to those two sensational scores just before the break.
Bath threatened to respond after the interval and the home fans were furious after Ben Spencer's score was chalked off for a knock-on in the build-up following a lengthy visit to the TMO.
But Bath soon had the score that put them back in front as they set up a lineout drive and sent hooker Jacques du Toit over.
Priestland converted and the game then started to become frantic, with both teams trying to find gaps across the field and the ball staying in play for a prolonged period.
Freeman did some fine covering work once again to get Saints out of jail, but Bath had their tails up and Naiyaravoro was forced into the sin bin after killing the ball on his own line.
But Saints, who had done so well with 14 men against Exeter six days earlier, came roaring back, putting together another patient move that was capped by a fine finish from Grayson.
But Grayson missed the conversion and Bath went back in front after Priestland notched a penalty.
When Naiyaravoro returned to the field, Bath were camped deep in Saints' half, lining up a lineout drive, from which the hosts almost scored, only for Tom Doughty to lose the ball over the line.
Doughty did ground the ball soon after as he flew in on the right, but his effort was disallowed for clear obstruction on Connor Tupai.
However, Ehren Painter was yellow carded for a lineout offence reducing Saints to 14 men for the second time as the pressure continued to build.
Saints eventually got out and had one final chance to launch an attack with Painter back on for the final minute, but Bath pinched the ball and Bayliss rounded things off with a fine breakaway try.
Priestland missed the conversion, meaning Saints would come away with a losing bonus point to add to the try bonus point they had earlier secured.
Bath: De Glanville (Bailey 78), Watson, Joseph, Ojomoh, Cokanasiga; Priestland, B Spencer (Chudley 71); Obano (Shoeman 52), du Toit (Doughty 60), Judge (Thomas 46); McNally, Ewels (c); Reid, Underhill (Mercer 52), Faletau (Bayliss 60).
Saints: Freeman (Gillespie 71); Collins, Dingwall, Hutchinson (Litchfield 57), Naiyaravoro; Grayson, Mitchell (Tupai 57); Waller (van Wyk 55), Haywood (Fish 55), Hill (Painter 55); Coles, Moon (Ratuniyarawa 53); Lawes, Ludlam (c) (Newman 71), Wood.
Referee: Ian Tempest