But Bath refused to lie down and looked the better outfit either side of half time despite Gloucester holding on to a 17-15 lead at the interval.
Chris Lewis' try as the hour mark approached looked to be decisive until Reuben Haile's interception try swung the game back in Gloucester's favour with nine minutes left only for Cook to have the last word.
It was a bright start for Gloucester as the pack drove powerfully though a well worked catch and drive. Dawidiuk and Dickinson carried well and Dan Robson fought his way to the line when the ball was moved wide. Mills converted for an early 7-0 lead.
Bath responded well and earned a couple of penalty opportunities for fly half Paul Roberts but both were pushed wide right of the target.
Gloucester regrouped and the second try duly followed. The pack again made the hard yards, driving to within a metre of the Bath line. The ball was popped up for Brett Deacon and the number eight smashed his way over. Mills added the extras.
Bath were capable of posing a threat and a powerful break by centre Nick Scott set up a promising position but Jacques Boussuge was bundled into touch at the corner.
However, the Gloucester lineout was overthrown and Bath prop Kane Palma-Newport took an offload to dive over. Roberts found his range and converted.
Bath were now in the game and more patient build up play led to a penalty chance for Roberts on 37 minutes and, head on to the posts, the fly half made no mistake.
And the visitors thought they'd finished the half on a high as they broke from deep in audacious style with left wing Isaac Weier finishing the move to give Bath the lead at 14-15 only for Mills to nudge Gloucester back in front with a penalty from the last kick of the half.
The second period started quietly but Bath centre Scott again broke clear, this time down the left flank, but the home defence got back to smother the danger as he passed inside.
However, the pressure from Bath was mounting and Ryan Mills was sinbinned on 54 minutes as Gloucester sought to keep the visitors at bay.
Outnumbered in the backs, a score was on the cards and Bath full back Chris Lewis was the extra man on 57 minutes and his try restored Bath's advantage at 17-20.
Time was against Gloucester but Reuben Haile picked off an errant pass and ran it back, showing great pace, to give his team the lead on 71 minutes.
Just three minutes later, when the obvious thing to do was to kick downfield, Gloucester tried to move the ball from deep, mishandled and Bath scrum half Chris Cook gathered and scampered under the posts. Roberts converted for 22-27.
Gloucester showed plenty of heart as they fought to get back on terms and no little enterprise but couldn't quite carve out an opening as Bath took the points.