Stockport County 2 Lincoln City 3
It looked all over when substitute Lee Frecklington made it 3-1 for the Red Imps after 78 minutes, but youngster Liam Dickinson hit back again on 83.
However, it wasn't to be enough and Lincoln ought to have made it four in stoppage time but Marvin Robinson and Steve Robinson missed near open goals.
Stockport created the first chance when the diminutive Adam Griffin stretched to head just over at the far post, but a hectic start saw Lincoln respond with Jamie McCombe heading straight at James Spencer.
The visitors had slightly the better of it early on and Francis Green blazed over from just 12 yards, but at the other end, twice within a couple of minutes, teenager Adam Le Fondre went close to adding to the three goals in his last three substitute appearances.
Lincoln goalkeeper Alan Marriott produced a brilliant double save to deny Matt Hamshaw and then Le Fondre, but again an end-to-end clash saw Stockport defender Mark Robinson forced into a goal-line clearance from a powerful Gareth McAuley header.
Stockport front-man Dickinson almost broke the deadlock just before the break, but his drive from just outside the box fizzed narrowly wide.
Lincoln raced out of the blocks after the break and within two minutes Green rose to head a Steve Robinson cross against the crossbar.
Just beyond the hour mark the game really burst into life with three goals in eight minutes. Lincoln struck first, with Martin Gritton pouncing on a rebound after Simon Yeo's free-kick was only parried by Spencer. But Stockport replied just as clinically as Keith Briggs rammed home from close range straight from a Hamshaw corner.
Yeo raced clear before burying a shot from 20 yards to regain the lead for Lincoln and then, with 12 minutes to go, it looked all over when Frecklington doubled the advantage.
Dickinson squeezed home a shot to reduce the deficit for Stockport, but Gannon's side couldn't quite fashion an equaliser.