Longford squandered a four-point lead in the second-half and fell to their fourth defeat of the campaign as Galway won 3-11 to 3-07 in this Allianz Football League tie at Pearse Park.
Sean McCormack scored 2-4 for Longford but it was not enough as Galway hit back with goals from Eoin Concannon and Paul Conroy to seal a second win of the campaign for the Tribesmen.
The loss leaves Longford in serious relegation trouble but Galway will now strive for promotion.
Galway led by 1-6 to 1-5 at the interval despite playing against the breeze.
They got a big boost when Michael Meehan scored a goal after 11 minutes.
But Longford responded and Donal McElligott was at the end of a good passing movement to find the net after 17 minutes and tie the scores at 1-3 each.
The impressive Niall Coleman edged Galway in front and then Michael Martin floated over a couple of points, but Longford finished the half strongly with Colm Smith and McElligott scoring to leave the minimum between them at the break.
Meehan and Eoin Concannon landed points inside 45 seconds of the restart for Galway and with the breeze behind them they looked set to push on.
But then David Barden set up McCormack for his first goal after 38 minutes and then two minutes later he dispossessed Micheal Boyle and again fired to the net to put Longford 3-5 to 1-8 in front.
McElligott extended that to four points after 45 minutes before Galway responded when Concannon fisted home a cross from Michael Martin after 55 minutes.
Niall Coleman equalised and then McCormack and Martin exchanged points to tie the sides for the sixth time nine minutes from the end.
Both sides missed good chances in the closing moments but then came the crucial score when the Longford defence failed to deal with another Martin delivery and Paul Conroy fisted home the winner in a crowded goalmouth.
Wing-back Gary Sice then burst forward in the dying moments to land an insurance point for the Tribesmen and keep their promotion hopes very much alive.
Longford scorers: S McCormack 2-4 (0-3f), D McElligott 1-2, C Smith 0-1.
Galway scorers: M Meehan 1-1, P Conroy 1-1, E Concannon 1-1, M Martin 0-5 (2f), N Coleman 0-2, G Sice 0-1.
Longford: D Sheridan; D Brady, B Gilleran, F Battrim; M Quinn, C Smith, S Mulligan; J Keegan, M Brady; B McElvanney, D McElligott, A Rowan; F McGee, D Barden, S McCormack.
Subs: N Mulligan for Rowan 32, K Diffley for Keegan 34, D Reilly for Diffley 60, P McCormack for Barden 65, P Foy for Quinn 70.
Galway: J Egan; J Duane, F Hanley, G Sweeney; G Bradshaw, G O’Donnell, G Sice; N Coleman, A Griffin; J O’Brien, P Conroy, M Boyle; E Concannon, M Meehan, M Martin.
Subs: F O Curraoin for Griffin 43, S Armstrong for Boyle 48, K Kelly for Bradshaw, 49, D Cummins for Meehan 58, S Denvir for Concannon 68.
Referee: N Mooney (Cavan).