Bath made a powerful start in pursuit of a first win on Gloucester soil since 2006 after fly-half Stephen Donald converted his own first-minute try and then kicked a penalty.
But Gloucester responded from 10-0 adrift through two Freddie Burns penalties, before he added the extras to full-back Rob Cook's 50th-minute touchdown and then slotted a late drop-goal.
Bath will wonder how they let things slip, especially given their early set-piece control, yet Gloucester were in no mood to relent once they set the scoreboard moving.
Burns, who has played himself into England fly-half contention ahead of the autumn Tests, came up trumps at key moments of an attritional contest.
His kicking contribution made the difference as Gloucester added Bath to their list of early-season scalps, and they will head into their European campaign next week unbeaten since September 1.
They are threatening a place in the play-offs at this early stage of the season, but Bath remain an erratic combination that has yet to settle under the coaching direction of Gary Gold and Toby Booth.
England number eight Ben Morgan returned from injury for Gloucester, while centre Henry Trinder and hooker Huia Edmonds also started and New Zealand scrum-half recruit Jimmy Cowan was on bench duty as the home side looked to make it five Premiership games unbeaten.
Bath were captained by former England hooker Lee Mears in the absence of an injured Stuart Hooper. Dominic Day and ex-Gloucester lock Dave Attwood formed Bath's second-row partnership, with Leicester old boys Sam Vesty and Dan Hipkiss teaming up at centre.
And the visitors made a stunning start, claiming the season's quickest Premiership try after just 32 seconds when Donald made a brilliant 40-metre break.
The New Zealander's sold Gloucester centre Billy Twelvetrees an audacious dummy, then sprinted clear for an opportunist touchdown that he also converted.
Gloucester were rocked on their heels, and they almost fell further behind 13 minutes later when brilliant work along the touchline by Bath wing Kyle Eastmond looked to have created a try for full-back Nick Abendanon.
But television match official David Grashoff rightly ruled that Eastmond had a foot on the touchline, and Gloucester escaped.
Gloucester, though, could not get into the game, with Bath enjoying scrummaging supremacy through the efforts of their Wales international loosehead Paul James and dictated the flow accordingly.
Donald booted a 21st-minute penalty to extend Bath's lead, but Gloucester secured enough territory late in a low-key half that reaped two penalty chances which Burns accepted.
Bath trooped off just four points clear, yet they will wonder why it was not a more convincing advantage given how Gloucester had lacked fluency or enjoyed any sustained spells of pressure.
Gloucester had chances to make life more difficult for Bath early in the second period, but Burns missed a penalty before brilliant defensive work by visiting wing Tom Biggs prevented a certain try.
Biggs' opposite number Shane Monahan set off on a superb angled run towards Bath's line, but Biggs - despite conceding considerable height and weight advantage -got underneath his opponent and prevented the touchdown.
Gloucester, though, only had to wait another three minutes before they breached Bath's defence, and this time it was Monahan's fellow wing James Simpson-Daniel who did the damage.
Cropping up in midfield, Simpson-Daniel fixed the Bath defence sufficiently to create space out wide, and former Cornish Pirates player Cook touched down.
Burns slotted the touchline conversion, and Gloucester held a three-point lead after fighting back impressively.
Bath looked to re-establish themselves in the game, but Gloucester possessed sufficient game-management skills to retain control, and Burns' 74th-minute drop-goal sealed the deal.
Gilbert has released a new line of rugby cleats. The Gilbert Virtuo 8S is part of the exciting new product. Check it out.
The entire All Blacks apparel line has been updated for 2013/14. Check out the New Zealand All Blacks polo.
The Nike Tiempo is a solid rugby cleat and one of few styles still made from full-grain natural leather.
The Gilbert Blitz 8S rugby cleat is a great cleat at a great price of $69.99. Get a new pair of cleats today.
A cool looking all black rugby cleat with the high performance adidas is known for. Get in the Gear!
Wear the crest of the British and Irish Lions on your t-shirt. A great look for the summer.
The All Blacks Performance t-shirt is black with hints of blue from the training jersey. Very Cool.
The New Zealand All Blacks training jersey for 2013/14. Get in the Gear!
The USA Rugby Pro Alternate rugby jersey is perfect for any fan of the Eagles. Get yours to wear during the summer Test matches.
The NEW All Blacks 2013/14 jersey has arrived at World Rugby Shop. Dare to wear the colors of the All Blacks.