The impressive Jordan Graham completed the rout three minutes from time after he was brought down in the area, before picking himself up to beat Alex Palmer from the penalty spot.
Story of the match
Lincoln began brightly and almost went ahead in the fourth minute. After Adam Jackson connected with Brennan Johnson's corner the ball flashed across the face of goal, but nobody could get the decisive touch.
It was the visitors who took the lead, however, in their first foray into Imps territory. Following a throw on the right, Jordan Graham stood the ball up perfectly for Vadaine Oliver to nod the ball past Alex Palmer from six yards out.
The Gills doubled their lead 10 minutes later through captain Kyle Dempsey, who latched on to Oliver's flick between Lincoln's centre backs and guided the ball beyond Palmer (above).
Lincoln were fortunate not to be further behind in the 32nd minute when John Akinde showed excellent footwork and unselfishness to tee up Dempsey, whose shot was brilliantly kept out by Palmer. Dempsey then slipped as the ball rebounded and Graham smashed the ball just over from close range.
A succession of Gillingham corners on the stroke of half time almost led to another goal, but the unmarked Connor Ogilive headed off target from Dempsey's delivery.
After the break a quick Johnson free kick found Liam Bridcutt on the edge of the area, but his shot deflected wide at the back post.
Another chance went begging on the hour as left back Tayo Edun controlled Callum Morton's pass before curling goalwards from 25 yards, but Gills keeper Jack Bonham tipped the ball on to the bar and it bounced behind.
The Imps went close again in the 72nd minute as Edun did well to break down the left before finding Regan Poole, but he saw his effort crash inches wide of the post.
That was as close as the Imps came, and it got worse for the home side three minutes from time when substitute Cohen Bramall brought down Graham with a poor challenge three minutes from time. Graham dusted himself down and fired past Palmer to spark jubilant scenes in the away dugout.
Takeaways from the match
Michael Appleton's side are now in real danger of falling away from the promotion picture after an alarming run of one win in seven games has seen the Imps fall well behind top two Hull City and Peterborough United.
Next up for the Imps is a tricky fixture away at Appleton's old club Oxford United on Saturday.
Steve Evans' Gillingham, meanwhile, have put together a decent run of four wins in five, which has propelled them to within a point of the top six.
The Gills have been in excellent goalscoring form too, netting 12 times in their last five outings.
Leading scorer Vadaine Oliver proved a constant nuisance on his return to the LNER Stadium, but it was Jordan Graham who stole the show at the heart of all the Gills' creativity.
The right-winger capped an excellent performance with a goal he deserved.