Gillingham conjured up a narrow victory at Chesterfield to cement their place at the top of League Two.
In a lacklustre first half, the visitors' Chris Whelpdale forced Tommy Lee into a fantastic low early save.
Just after the break Cody McDonald broke the deadlock, glancing in Myles Weston's corner for his fourth goal in his second Gills loan spell.
Despite being behind, the hosts failed to exert pressure, but Jack Lester did have a strike ruled out for offside.
Lester also had a tame half-volley saved comfortably by Gills keeper Stuart Nelson and the Spireites remain 12th in League Two.
But McDonald's strike means Gillingham remain two points ahead of closest rivals Port Vale, who kept up the pressure on the Gills with a 1-0 win at Torquay.
It was the Kent outfit's 11th away win of the season, setting a new club record.
VIEWS FROM THE DRESSING ROOM
Chesterfield manager Paul Cook told BBC Radio Sheffield:
"They scored from a set play and we've worked so hard this week on set plays again.
"We were at fault last weekend at Rotherham and unfortunately it's happened again today and that's the disappointment.
"Second half I felt we could have gone on and won the game and unfortunately for us it never happened.
"I certainly can't fault any effort or application today, but we weren't good enough and we're not scoring enough goals."
Gillingham manager Martin Allen told BBC Radio Kent:
"It's a historic day, it's for the football club, the supporters, players and the chairman. I'm proud to be the manager to get this record [of 11 away wins in a season].
"We played fantastic football today.
"The pitch wasn't as good as I expected, the last 20 minutes was a bit scary but I've seen it a million times, and when we defend in numbers we're strong.
"That's the first goal we've scored away from home from a corner for 16 games. To score from a set piece we've worked on makes me very happy.
"It was probably the longest game in the history of football matches. Seven minutes stoppage time? I thought 'Match of the Day is going to start in a minute'."
Sorry, we were unable to load match stats, please try again.
Live Text Commentary
Full Time The final whistle goes and the game is over.90:00 +7:04
Tommy Lee takes the free kick.90:00 +7:04 Booking
Booking Myles Weston is cautioned.90:00 +6:49
Myles Weston challenges Drew Talbot unfairly and gives away a free kick.90:00 +6:26
Short corner worked by Myles Weston.90:00 +4:19
Adam Barrett challenges Jack Lester unfairly and gives away a free kick. Direct effort from the free kick comes in from Conor Townsend, save by Stuart Nelson.90:00 +0:17
Deon Burton is caught offside. Free kick taken by Tommy Lee.89:37
The referee blows for offside against Jack Lester. Free kick taken by Stuart Nelson.89:08
The referee blows for offside. Tommy Lee takes the indirect free kick.85:26
Alex Henshall takes the outswinging corner, clearance made by Deon Burton.82:03 Booking
Booking Stuart Nelson is given a yellow card.81:33
Drew Talbot sends in a cross, Jack Lester has a headed effort at goal from close in which goes wide left of the goal.79:57 Substitution
Substitution Jordan Clark is brought on as a substitute for Neal Trotman.79:33
Sam Togwell takes a shot. Save by Stuart Nelson.78:19
Deon Burton takes a shot. Richard Brindley gets a block in. Myles Weston takes the outswinging corner, Liam Cooper manages to make a clearance.77:47
Foul by Conor Townsend on Callum Davies, free kick awarded. Chris Whelpdale takes the free kick.77:08
Anton Robinson gives away a free kick for an unfair challenge on Drew Talbot. Direct free kick taken by Tommy Lee.76:27
Corner taken left-footed by Myles Weston from the right by-line, Leon Legge takes a shot. Save by Tommy Lee.70:13
Myles Weston takes a shot. Save made by Tommy Lee.68:26
The referee blows for offside against Myles Weston. Tommy Lee takes the free kick.
Deon Burton shoots direct from the free kick, save by Tommy Lee. Corner taken left-footed by Myles Weston. Inswinging corner taken from the left by-line by Anton Robinson, Neal Trotman manages to make a clearance.66:09 Booking
Booking Sam Togwell goes into the referee's book for unsporting behaviour.65:49
Free kick awarded for an unfair challenge on Joe Martin by Sam Togwell.65:01
Effort from the edge of the box by Conor Townsend goes wide of the left-hand post.63:15
The ball is delivered by Charlie Lee, Nathan Smith manages to make a clearance.61:39
Drew Talbot produces a cross, Stuart Nelson makes a comfortable save.60:30
Myles Weston produces a right-footed shot from just outside the area that goes harmlessly over the target.58:42 Substitution
Substitution Callum Davies replaces Cody McDonald.58:24
Charlie Lee concedes a free kick for a foul on Neal Trotman. Tommy Lee takes the direct free kick.56:40
Effort on goal by Conor Townsend from outside the area goes harmlessly over the bar.56:12
Alex Henshall crosses the ball. Corner taken by Alex Henshall from the left by-line, Leon Legge makes a clearance.55:21
Corner from the right by-line taken by Alex Henshall, Myles Weston makes a clearance.54:18
Foul by Anton Robinson on Drew Talbot, free kick awarded. Tommy Lee restarts play with the free kick.52:24 Substitution
Substitution (Chesterfield) makes a substitution, with Alex Henshall coming on for James O'Shea.52:24 Substitution
Substitution (Chesterfield) makes a substitution, with Jack Lester coming on for Craig Clay.49:07
The assist for the goal came from Myles Weston.49:07 Goal scored
Goal! - Cody McDonald - Chesterfld 0 - 1 Gillingham Cody McDonald scores a headed goal from close in. Chesterfield 0-1 Gillingham.48:44
Inswinging corner taken left-footed by Myles Weston from the left by-line,45:42
The ball is crossed by Drew Talbot, clearance by Adam Barrett.45:01
The referee starts the second half.45:00 +2:13 Half time
Half Time The players leave the pitch at half time.45:00 +1:40
Joe Martin restarts play with the free kick.45:00 +1:40 Booking
Booking James O'Shea receives a yellow card.45:00 +1:20
Anton Robinson fouled by James O'Shea, the ref awards a free kick.45:00 +0:12
Unfair challenge on Drew Talbot by Steven Gregory results in a free kick. Tommy Lee takes the direct free kick.45:00 +0:06
Myles Weston produces a cross, Nathan Smith manages to make a clearance.44:16
Direct free kick taken by Myles Weston.44:16 Booking
Booking Booking for Liam Cooper for unsporting behaviour.43:53
Liam Cooper concedes a free kick for a foul on Cody McDonald.42:59
Craig Clay fouled by Chris Whelpdale, the ref awards a free kick. The free kick is swung in right-footed by Conor Townsend, Steven Gregory makes a clearance.41:48
Effort from the edge of the penalty box by Drew Talbot goes wide of the right-hand upright.36:28
The ball is sent over by Chris Whelpdale, Neal Trotman makes a clearance.36:13
Myles Weston crosses the ball, clearance by Neal Trotman.35:52
The ball is crossed by Charlie Lee, Neal Trotman makes a clearance.34:58
Effort on goal by James O'Shea from long range goes over the crossbar.34:39
Nathan Smith sends in a cross, save by Stuart Nelson.33:05
The ball is crossed by Charlie Lee, clearance made by Nathan Smith.30:41
The offside flag is raised against Joe Martin. Tommy Lee restarts play with the free kick.30:30
A cross is delivered by Joe Martin, clearance by Neal Trotman.29:01
Shot by Joe Martin from 18 yards. Save by Tommy Lee.27:00 Substitution
Substitution Deon Burton comes on in place of Matt Fish.25:55
The ball is crossed by James O'Shea, save made by Stuart Nelson.25:11
Centre by Sam Togwell.24:22
Leon Legge challenges Marc Richards unfairly and gives away a free kick. Free kick crossed right-footed by Nathan Smith from left channel, clearance by Joe Martin.23:08
Charlie Lee delivers the ball.22:22
Shot by Marc Richards from just outside the area goes over the net.20:55
Chris Whelpdale gives away a free kick for an unfair challenge on Nathan Smith. James O'Shea crosses the ball from the free kick right-footed from left wing, Foul by Neal Trotman on Steven Gregory, free kick awarded. Free kick taken by Stuart Nelson.18:55
Charlie Lee produces a cross, clearance made by Richard Brindley.18:08
The ball is swung over by Myles Weston, clearance by Liam Cooper.17:12
Inswinging corner taken by Charlie Lee from the right by-line played to the near post, Sam Togwell makes a clearance. Short corner taken by Charlie Lee.15:56
Myles Weston takes the outswinging corner, Leon Legge has a headed effort from close range and clears the crossbar.14:34
Free kick awarded for an unfair challenge on Anton Robinson by Sam Togwell. Myles Weston takes the direct free kick.11:37
Anton Robinson produces a right-footed shot from just outside the box that goes wide left of the goal.9:37
A cross is delivered by Joe Martin.9:06
Outswinging corner taken left-footed by Myles Weston, clearance made by Neal Trotman. Charlie Lee takes a shot. Save made by Tommy Lee.8:28
James O'Shea concedes a free kick for a foul on Joe Martin. Leon Legge takes the free kick.6:52
Outswinging corner taken left-footed by Myles Weston from the left by-line, James O'Shea makes a clearance.6:37
The ball is sent over by Charlie Lee, save by Tommy Lee.6:15
The ball is crossed by James O'Shea, clearance made by Leon Legge.5:17
Cody McDonald fouled by Drew Talbot, the ref awards a free kick. Free kick taken by Stuart Nelson.4:45
Joe Martin sends in a cross, save by Tommy Lee.2:58
Free kick awarded for a foul by Cody McDonald on Sam Togwell. Richard Brindley takes the direct free kick.2:24
A cross is delivered by Sam Togwell, Leon Legge manages to make a clearance.0:59
Effort from the edge of the box by Charlie Lee goes wide of the left-hand upright.0:00
The match gets underway.
Live data and text provided by our data suppliers