Dunfermline climbed into the play-off places with a victory in Dumfries which left Queen of the South just two points off bottom spot.
In a lively opening there had been chances at either end before Gary Oliver latched on to a Stephen Dobbie pass to fire Queens ahead.
Their advantage was short-lived, though, as Pars hit back through Gabby McGill who was first to react after Jonathan Afolabi’s initial effort rebounded from the bar.
Queens forced a string of corners as they attempted to get their noses back in front but the visiting defence held firm. And the Fifers took advantage on the stroke of half-time to claim the lead when Danny Devine rose to head a Don Thomas corner beyond home keeper Ross Stewart.
Owain Fon Williams was in action soon after the restart, making a low diving save to keep out Iain Wilson’s netbound effort.
But the visiting keeper was beaten from the spot by Stephen Dobbie after the striker himself had been upended by Devine.
The Pars almost restored the lead when Thomas sent a shot narrowly over as the game entered the final quarter.
Thomas turned provider for the second time eight minutes from time with another corner which found Lee Ashcroft rising above the Queens defence to power in an unstoppable header.