Nicky Southall returned to haunt his former club with a second-half winner as he handed Nottingham Forest all three points.
Southall struck in the 57th minute with a simple finish to relieve the pain of last week's home thrashing by Scunthorpe United.
Both sides had shipped four goals in their previous games and appeared nervous early on as several passes went astray. But after 13 minutes Ian Cox's downward header from Clint Easton's corner needed a goal-line clearance by Southall.
Moments later, Southall turned provider with a precise pass that Junior Agogo could only blast into the side-netting.
And on 29 minutes Agogo missed a golden opportunity to put the league leaders in front when he latched onto a long ball and held off Ian Cox, before blazing over with only Scott Flinders to beat.
Matt Jarvis should have punished that miss a minute later but his12-yard shot was brilliantly tipped over by Forest keeper Paul Smith.
Neither side were able to stamp their authority on the game and, as the half drew to a close, Easton attempted a spectacular volley from 40 yards that landed on the roof of the net.
The second half resumed the pattern of the first until the visitors struck on the counter-attack in the 57th minute. Agogo released Kris Commons who burst into the area before delivering a low cross for Southall to tap home.
Forest appeared content to shut up shop but were perhaps fortunate not to concede a penalty when Guylain Ndumbu-Nsungu appeared to be bundled over in the area by Wes Morgan.
Gillingham, although enjoying plenty of possession, were reduced to a series of half-chances, although Smith had to be alert to tip over Easton's 69th minute free-kick.
Substitute Dean McDonald injected some pace and managed to squeeze in a shot that was straight at Smith as time began to run out.
In the final minute Gillingham's hopes of snatching a point all but ended when Mark Bentley headed over a decent chance from McDonald's cross.