George Ford kicked all Bath's points as they went second in the Premiership by beating local rivals Gloucester.
All of the points in a tight first half came from penalties, with Ford kicking three for Bath and Freddie Burns replying once for the visitors.
Bath stretched their 9-3 half-time lead with another Ford penalty, but Burns added a try, conversion and penalty to keep Gloucester in touch.
Ford took his tally to 15 points as Bath recorded a dramatic win.
There was a cautious opening from both sides in the pouring rain and Ford put the hosts ahead with a second-minute penalty.
The rain relented but it was an error-strewn half, with neither side able to stamp their authority on the game.
A strong period of Bath pressure resulted in Ford adding his second and third penalties of the night.
Gloucester's Burns successfully landed his first attempt at goal soon after, while Ford missed for the first time as he twice put 30-metre kicks across the face of goal.
Bath, unbeaten at home this season, increased their six-point half-time lead with Ford's fourth successful penalty.
But he missed a simple attempt to stretch the home side's lead further as his kicking continued to be erratic, while Burns hit the upright at the other end.
Rupert Harden was sin-binned but, rather than hamper Gloucester, it spurred the visitors on to the game's first try, as Burns raced over after a Bath error and he also added the extras.
Ford made it five penalties from eight to increase Bath's lead again, but Burns hit back immediately against his former club to take his haul to 13 points.
With the clock ticking down, Ford missed an attempt to open up a five-point lead with another unsuccessful kick, but it proved irrelevant in the end as Bath hung on for their fourth victory of the season.
VIEWS FROM THE DRESSING ROOM
Bath head coach Mike Ford:
"I thought we dominated the game. We put ourselves under pressure though, missed a few goal kicks, conceded a charge-down try. But apart from that, I thought we were dominant in most facets.
"We are second now and we're pleased where we are. Conditions didn't help but we believe we've only scratched the surface with this team.
"There were some pleasing things. I'm not disappointed about winning derby games."
Gloucester director of rugby Nigel Davies:
"Overall, it was a poor game of rugby. I was disappointed with elements of our performance but the biggest disappointment for me was our discipline.
"If we had remained disciplined we could have sneaked something out of that game.
"There were periods of the second half where the momentum had changed, we had good field position, we could have have put pressure on Bath, but because we were undisciplined we didn't."
Bath: Watson; Rokoduguni, Joseph, Eastmond, Banahan; Ford, Stringer; James, Webber, Perenise; Hooper (capt), Attwood; Garvey, Louw, Fearns.
Replacements: Agulla for Eastmond (68), Catt for James (71), Batty for Webber (71), Orlandi for Perenise (63). Not Used: Spencer, Faosiliva, Roberts, Henson.
Sin Bin: Watson (67).
Gloucester: Cook; Simpson-Daniel, Tindall, Mills, May; Burns, Cowan; Murphy, Dawidiuk, Harden; Stooke, Hudson; Savage (capt), Kvesic, Kalamafoni.
Replacements: Robson for Cowan (56), Y. Thomas for Murphy (30), Edmonds for Dawidiuk (52), James for Hudson (52), Gibbons for Kvesic (58). Not Used: Evans, Sharples, Qera.
Sin Bin: Harden (54).
Referee: Wayne Barnes (RFU).