It had all been going so well for Chris Boyd's side, who stormed into a 19-3 lead thanks to a try double from Tom James and a first Saints score from Tommy Freeman.
But Bath gradually crept back into the game, despite being largely overwhelmed at the scrum, and a Zach Mercer score just before half-time was a crucial stepping stone.
Saints struggled to get any dominance after the break but did have some near misses as the impressive Lewis Ludlam was deemed to have knocked on while reaching for the line and Matt Proctor was held up.
It robbed the hosts of a chance of a try bonus point that could have put the game to bed, and Bath kept coming, with the boot of Rhys Priestland and determination of Mercer proving decisive.
Saints had one final chance deep in the Bath half, but the away side won a scrum penalty to relieve the pressure before seeing the game out to record their third successive victory.
Saints had gone into the game on the back of a brilliant win at Exeter, which was built on defence and set-piece dominance.
And the black, green and gold were bossing the early scrum battle against Bath, winning two early penalties that laid the platform for a rapid attack, which ended with Rory Hutchinson almost scoring in the corner.
Bath were under pressure and after Saints kicked a penalty to the corner, they engineered their first score, with Tom James finishing superbly.
Piers Francis sent the conversion just wide of the right upright but he made amends after a vintage Saints score that saw Taqele Naiyaravoro offload brilliantly for the onrushing James to score his second of the game.
Rhys Priestland responded with a penalty earned at the scrum, cutting the gap to nine points after 25 minutes.
But Saints were straight back on the front foot, cutting Bath apart at will, with George Furbank sending full-back Freeman over for his first Northampton score.
Francis converted again and Saints were just one try away from the bonus point with only 28 minutes gone.
But Bath were next to score, putting together a five-minute spell of possession deep in Saints territory and eventually forcing their way over through menacing No.8 Mercer.
Priestland notched the conversion to reduce the deficit to nine points at the break, during which Saints sent on Paul Hill for Ehren Painter.
Bath were soon replacing their entire front row seven minutes into the second period, just after referee Ian Tempest had warned them that one more penalty would see a player sent to the sin bin.
The trend continued though as Saints immediately won a penalty from the new-look Bath pack, but the away side responded with a call of their own that allowed them to clear their lines.
Saints thought they'd got their bonus-point score on 52 minutes when the lively Proctor flew down the right and Ludlam eventually picked up the pieces and dived towards the line.
But Ludlam was deemed to have knocked on while trying to ground the ball and Bath escaped.
The away side were starting to look more dangerous and after Saints had to scramble to stop a score, Priestland landed a penalty to eat into the lead further.
Bath were now applying real pressure, threatening to score before earning a penalty, which gave Priestland another three points.
It meant Saints were just three ahead going into the final 18 minutes of the match, and nerves were starting to jangle.
The home side needed a response and they got it from Naiyaravoro, who flew down the left wing and was only denied a try by a brilliant saving tackle from Ben Spencer.
Saints did go on to win a penalty though, allowing Francis to extend their lead.
But Bath would not go away and Mercer flew forward to claim a crucial score, giving Priestland the chance to notch a conversion that gave the men in white the lead for the first time.
Bath thought they'd scored again soon after but there was a knock-on and Saints breathed again.
However, the black, green and gold were stuck in their own half, desperately seeking a route out.
Eventually they found a way to get back into Bath's 22, setting up a couple of scrum penalties five metres from the line.
Saints opted not to go for goal, taking scrums, and it was a decision that was to cost them dear as Bath survived, winning a penalty of their own and escaping with three minutes to go.
Saints couldn't get the ball back in a dangerous position to threaten and Bath booted the ball out before celebrating wildly as they secured a narrow success.
Saints: Freeman (Mallinder 65); Proctor, Hutchinson, Francis, Naiyaravoro (Sleightholme 68); Furbank, James (Taylor 61); Auterac (Waller 52), Matavesi (Marshall 73), Painter (Hill 40); Ribbans, Ratuniyarawa (Moon 57); Isiekwe, Ludlam (c), Wood (Coles 70).
Bath: T Schoeman (McConnochie 52); Rokoduguni, Joseph (Clark 67), Matavesi (Joseph 70), Muir; Priestland, Chudley (Spencer 57); J Schoeman (Bhatti 47), Walker (Dunn 47), Judge (Thomas 47); Ellis, Stooke; Bayliss (c), Reid, Mercer.
Referee: Ian Tempest