Morecambe marked their 200th Football League game with a win to take them up to third in the League 2 table.
The Shrimps took the lead in the eighth minute when Garry Hunter scored his first of the season with a delightful volley. Hunter received the ball on the edge of the area and his effort dipped late to end up under the crossbar.
Gillingham hit back with long range efforts from Luke Rooney and Chris Whelpdale with Charlie Lea inches away from connecting with a right wing cross.
Gillingham enjoyed the early pressure in the second half without ever really threatening the Morecambe goal and the Shrimps' resistance paid off when Kevin Ellison came off the banch to double the home side's advantage on 69 minutes after good work from Stewart Drummond and Izak Reid.
Morecambe keeper Barry Roche made an excellent save from Chris Whelpdale's long range effort before conceding an injury time penalty wheh he brought down Joe Kuffour after the striker ran on to Lewis Alessandra's poor back pass.
Frank Nouble scored from the spot but the Shrimps held on for a very welcome home win.
Morecambe: Roche; Haining, Parrish, McCready, Wilson; Drummond, Hunter, McDonald; Alessandra, Price, Carlton. Subs: Routledge, Charnock, Ellison, Reid, Fleming.
Gillingham: Flitney, Fish, Richards, Lawrence, Jackman; Rooney, Lee, Weston, Whelpdale; Nouble, Kuffour. Subs: Frampton, Kedwell, Martin, Payne, Gazzaniga (GK)
Ref: C Boyeson.