Dany N'Guessan struck a late winner for Lincoln as Gillingham lost at home for the first time since August.
The Gills took the lead when Simeon Jackson smashed home from the spot after defender Frank Sinclair shoved Adam Miller to the floor.
Lincoln levelled in the second half with Geoff Horsfield firing in from 35 yards - his first for nearly a year.
As the visitors headed for a fourth successive draw, N'Guessan broke clear to grab the winner and three points.
Gillingham: Royce, Lewis, Richards, Bentley, Nutter, Southall, Weston, Miller, Barcham, Jackson, Oli. Subs Not Used: Mulligan, Julian, Cumbers, Steer, Peters.
Booked: Bentley, Miller.
Goals: Jackson 25 pen.
Please turn on JavaScript. Media requires JavaScript to play.
Subs Not Used: Duffy, Swaibu.
Booked: Burch, Horsfield.
Goals: Horsfield 52, N'Guessan 90.
Att: 4,525
Ref: Simon Hooper (Swindon).
What are these?
Print Sponsor
Bookmark with:
What are these?