An excellent performance from Brian Barry-Murphy's Rochdale resulted in a first win in 10 games.
Dale, who had failed to score in their previous six games, finally found the net through Oliver Rathbone's first-half strike.
Morgan Rogers scored for the third consecutive game to equalise for Lincoln in stunning fashion, but Stephen Humphrys won it late on.
Story of the match
With the wind behind them, it was Rochdale that began brightest, winning four corners inside the opening six minutes. The third of these saw Conor Shaughnessy head goalwards from Conor Grant's delivery - only for Imps goalkeeper Alex Palmer to pull off a fine one-handed save.
A fifth corner on 17 minutes again found Palmer on alert, who this time reacted quickest to keep out Stephen Humphrys from close range.
Yet another corner a minute later found its way through a crowded penalty area to defender Eoghan O'Connell, but he couldn't keep his first-time volley low enough to threaten Palmer.
Lincoln finally carved out a decent chance of their own in the 23rd minute, but Conor McGrandles' goal-bound shot from Brennan Johnson's cross hit teammate Callum Morton and bounced to safety.
The visitors' dominance paid off nine minutes before the interval as Oliver Rathbone kept his composure to fire a low effort beyond Palmer into the bottom corner from the edge of the area. It clearly meant a lot to his side - who all ran to celebrate with boss Brian Barry-Murphy in the away dugout (above).
A poor free-kick from Lincoln's James Jones at the end of the half allowed Rochdale to break with Matt Done chasing Rathbone's long, diagonal pass. His cross was met by the onrushing Humphrys, who could only clip his attempt just wide.
Lincoln made a change at half time introducing Anthony Scully for Cohen Bramall.
Five minutes into the half Done teed up Humphrys in the Lincoln area and the Imps had Palmer to thank as he pulled off a superb stop deny Dale a second.
Moments later it was McGrandles who saved Lincoln, who cleared a bullet header from Gabriel Osho off the line with Palmer beaten.
The Imps levelled on the hour against the run of play thanks to a stunning strike from Rogers. The forward cut in from the left and played a one-two with Morton before unleashing an unstoppable shot into the top corner.
Five minutes later Lincoln went close to turning the game on its head, but Rochdale goalkeeper Gavin Bazuna tipped Johnson's dipping 25-yard strike just over.
Rochdale regained the lead with 16 minutes to go, however, as Humphrys carved out an opening for himself before firing a shot past Palmer that bounced off the inside of the post and trickled over the line.
In response, Lincoln threw on another striker in Tom Hopper and he soon won a free kick in a dangerous position on the edge of the area. Johnson stepped up and curled the free-kick over the wall and over the bar, however.
It was all hands on deck in the dying stages as Lincoln looked to earn a point, but Dale hung on.
Michael Appleton's side missed the chance to move into the automatic promotion places with this dismal display.
With rivals Peterborough United not in action, the Imps were presented with an ideal opportunity to go second but fluffed their lines.
The Imps also lost further ground on leaders Hull City, who beat Oxford United.
Rochdale ended a run of nine games without a win to move off the bottom of League One with this unexpected but thoroughly deserved victory.
In doing so, Brian Barry-Murphy's men finally found the net (twice), having not scored in their previous six matches.
Matt Done and Conor Grant were at the heart of all Rochdale's decent creativity, but in truth, every player played their part in this crucial win.
Stephen Humphrys, meanwhile, lead the line superbly and was rewarded with the winning goal.