Enda Lynn opened the scoring for the hosts but Longford equalised with a superb score from their best forward, Bernard McElvaney. He was to land three brilliant efforts from play and Longford were well in the game at half-time, trailing 0-5 to 0-2.
The gap was narrower still by the threequarters stage when Glenn Ryan’s side pulled themselves back to within two, 0-6 to 0-4.
But Derry hit eight of the game’s last nine points as they kept themselves in the hunt on a night when Louth and Laois also recorded important victories.
DERRY: E McNicholl; G O’Kane, C McKaigue, D McBride; C Kielt, M Lynch (0-1), SL McGoldrick; Patsy Bradley, PJ McCloskey; A McAlynn, J Kielt (0-4, 0-1f), E Lynn (0-2); D Heavron (0-1), E McGuckin, L Kennedy.
Subs: E Bradley (0-3, 0-2f) for Kennedy (23), R Wilkinson (0-2) for McGuckin (HT), M Bateson for Lynch (43), B Heron for C Kielt (56), Philip Bradley for McCloskey (68).
LONGFORD: D Sheridan; D Brady, B Gilleran, D Reilly; C Smyth, F Battrim, S Mulligan; M Brady, J Keegan; B McElvaney (0-3), D McElligot, A Rowan; F McGee, D Barden, S McCormack (0-2f).
Subs: P Foy for McElligot (HT), JJ Matthews for Rowan (54), JP Reilly for Barden (59), S Doyle for Smyth (66).
Referee: C O’Hagan (Tyrone).