Lewis Montrose put the Gills ahead when an error by Morecambe goalkeeper Barry Roche allowed him to roll the ball into an empty net.
Morecambe looked to have done enough to take a point away from the league leaders when substitute Jack Renshaw converted Kevin Ellison's cross from close range but Deon Burton was on hand to deny them any points with an injury-time half volley.
Port Vale dropped points at home after York came from two goals down to engineer a 2-2 draw at Vale Park.
Ryan Burge's score and a penalty by Jennison Myrie-Williams put the home side in front but second-half goals by Alex Rodman and Jamie Reed earned York a point and extended Port Vale's winless run to five league games.
Third-placed Cheltenham also dropped points as they were beaten 4-2 by Rotherham at the New York stadium.
Keith Lowe's first-minute score for Cheltenham was cancelled out three minutes later by Rotherham striker Daniel Nardiello before Ben Pringle put the home side ahead.
Nardiello extended Rotherham's lead in the 29th minute but it was cut two minutes later by Chris Zebroski as Cheltenham fought back.
Lee Frecklington made sure of the win in the 90th minute as Rotherham bounced back from last weekend's 5-0 thumping by Dagenham and Redbridge.
Fleetwood kept up the pressure on the top three with a 3-0 win over 10-man Plymouth.
David Ball scored in the second minute with an own goal by Plymouth's Curtis Nelson and a close range strike by Junior Brown enough for Fleetwood to win, with Plymouth defender Darren Purse sent off after 78 minutes.
Rochdale and Burton Albion both won as they looked to consolidate their place in the top six.
Rochdale beat nine-man Bristol Rovers 2-1 after they came from behind with goals from Andrew Tutte and Bobby Grant.
David Clarkson had opened the scoring for Rovers in the 14th minute from the penalty spot after Peter Cavanagh fouled Wayne Brown, but it was not enough, especially as Garry Kenneth was shown red for his second bookable offence in the 70th minute and Eliot Richards was given a straight red card in the 90th minute for a foul on Ashley Grimes.
Burton also came from behind to beat Dagenham and Redbridge 3-2.
Goals for Damien McCrory, Matthew Paterson and Billy Kee were enough for Burton as Dwight Gayle and Sam Williams scored for Dag and Red, with Michael Spillane missing what proved to be a crucial penalty.
Chris Atkinson's stoppage-time winner earned Chesterfield a 2-1 win over Oxford Utd.
Johnny Mullins scored after just 43 second for Oxford but Liam Cooper's score on the stroke of half-time and Chris Atkinson's last-gasp winner earned Chesterfield their first win in five games.
Adebayo Akinfenwa scored twice as Northampton powered to a 3-1 win at home to Wycombe.
Akinfenwa scored in open play and from the penalty spot, with Chris Hackett making sure of the win before Joel Grant's consolation spot-kick for Wycombe.
Two goals apiece for Britt Assombalonga and Gavin Tomlin saw Southend sink Torquay 4-1 at Plainmoor with four first-half goals.
Ryan Jarvis scored for the home side in the 52nd minute but it was scant consolation for Torquay who missed a good chance to move closer to the top six.
Elsewhere, Jamie Cureton's goal was enough for Exeter to sink Bradford 1-0 while AFC Wimbledon drew 1-1 against Aldershot when Daniel Lopez's goal for the Shots was cancelled out by Stacy Long.