Gillingham halted Bristol City’s winning run with a gritty performance against the league leaders.
City had most of the chances and bossed the second half but the Gills hung on.
The home side had gone into Saturday’s game buoyed by a run of five straight wins.
But the Gills weren’t lacking in confidence either after recent wins over some of League 1’s best sides.
New loan signing Oliver Muldoon started for the Gills while Aaron Morris also made the first XI as Josh Pritchard and Jake Hessenthaler dropped out.
Pritchard picked up a hamstring injury during last week’s draw with Doncaster while Hessenthaler was understood to be missing through illness.
It was Gillingham’s fifth meeting against Bristol City this season and they were searching for their first win.
The League 1 leaders had already beaten the Gills in the FA Cup, the two-legged Johnstone’s Paint Trophy area final and in the league.
Gills keeper Stuart Nelson wasn’t overly worked in the first half, with just one real save to make, getting down well for Joe Bryan’s low angled effort.
Justin Edinburgh’s side competed well against a side destined for Championship football next season, although home keeper Frank Fielding wasn’t troubled in the opening half.
Gills’ best early chance fell to Bradley Dack, lurking deep as Doug Loft’s corner dropped into the box, but he shot wide.
Loft screwed a long-range effort wide himself just before the break.
The Gills made a positive start to the second half but within five minutes of the restart City had a great chance to take the lead.
Marlon Pack floated in a cross and Aaron Wilbraham glanced a header narrowly wide. It was the start of a prolonged spell of pressure from the hosts.
With just over an hour gone Luke Ayling fired a good chance over the bar, following a corner. Moments later Wilbraham almost got on the end of a good cross from the dangerous Bryan.
Jermaine McGlashan’s introduction helped take some off the pressure from the Gills defence but the visiting defence continued to be asked questions by the league leaders.
Gillingham did have the ball in the net with seven minutes left, through Bradley Dack, but he was flagged for off-side. He deflected Luke Norris’ shot in after McDonald had broke for the visitors.
Nelson made a good save from Jay Emmanuel-Thomas, diving low and blocking the shot one-handed, with three minutes left. Former Gills player Luke Freeman also came close, firing a curling effort just over.
Egan’s fantastic challenge denied Emmanuel-Thomas on the stroke of 90 minutes and the Gills hung on to claim an impressive result.
Gillingham: Nelson, Hoyte, Martin, Egan, Ehmer, A Morris, Muldoon (McGlashan 67mins), Loft, Dack, Marquis (Norris 77mins), McDonald. Subs not used: G Morris, Legge, Galbraith, Dickenson, Romeo.
Bristol City: Fielding, Ayling, Bryan (Tavernier 75mins), Little, Williams (Cunningham 30mins), Flint, Smith, Freeman, Wilbraham, Agard (Emmanuel-Thomas 75mins), Pack. Subs not used: Richards, Elliott, Wagstaff, Saville.
Attendance: 11,601 (325 away)