A Joe Parker double and a bullet header from Matt Williams was enough to resist a late Bognor fightback.
Two late goals for the Rocks threatened to complete an extraordinary comeback at the Jubilee Stadium.
Keeper James Hamon produced a stunning last-minute save as the Tigers held on for a vital three points against the relegation strugglers.
After a quiet opening quarter, City fashioned the first chance of the game. Parker was played in down the right but saw his effort come back off the post from a tight angle.
Despite having most of the ball, City were struggling to carve out any clear-cut chances against a stubborn Rocks defence.
The first-half looked to be fizzling out to a goalless conclusion, but 8 minutes before the break, Hanks pounced on a defensive error and squared the ball to Joe Parker who slotted into the empty net.
Into the second-half, City began to put their foot down and the chances began to come more frequently.
Parker wasted a great chance to double the lead, the forward was played clean through but chipped the ball over the bar.
But the relentless City pressure finally told just before the hour mark, Ed Williams played through on the left saw his shot well saved, but Parker was well-positioned to finish the rebound.
The third came just over ten minutes from the end, Matt Williams bullet header from a corner left the keeper with no chance.
In the 88th minute with the points seemingly in the bag, City gave away a soft penalty which was converted by Ibra Sekajja.
The Rocks grabbed a second with a fantastic finish from Wood, the midfielder took advantage of some poor defending to smash the ball home.
With City hanging on in the dying minutes, Hamon produced a brilliant last-gasp save to prevent what would have been an extraordinary comeback.
The result lifts the Tigers up to 13th in the table and are now mathematically safe.
Man of the Match – Joe Parker
Hamon, Thomas (Hamilton 74), Parselle, Cundy, M.Williams, Knowles (Morford 81), Hanks, Webb (Edge 78), Parker, Ed.Williams, Hall,
Subs not used: Avery, Kelly
Next up for Gloucester City: Home vs. Dartford 10th April 19:45 KO
Post-match reaction will be available on the clubs YouTube channel as well as the website.
By Harry Hogg