Substitute Gavin Reilly scored a late winner as Queen of the South narrowed the gap on Raith Rovers to two points at the foot of the First Division.
Both sides had a number of chances in an open and entertaining first half, with Tom Brighton twice going closest for the home side.
But he was thwarted both times by Ross Laidlaw.
Rovers' best chance fell to top scorer John Baird in the 29th minute and he unleashed a shot from the edge of the area that was well held by Lee Robinson.
The winner came in the 82nd minute, when fellow substitute Kevin Smith picked out Reilly to fire into the bottom corner from 20 yards to give the Doonhammers their first win in six games.
Queen of South: Robinson, Alan Reid, McGuffie, Potter, Higgins, Carmichael (Reilly 77), McKenna, Johnston, McLaughlin (Simmons 76), Parkin, Brighton (Smith 70).
Subs Not Used: Atkinson, Craig Reid.
Goals: Reilly 82.
Raith Rovers: Laidlaw, Jason Thomson, Hill, Ellis, Dyer, Allan Walker, Davidson, Murray, Hamill (Williamson 83), Baird (Jamie Walker 76), Casalinuovo (Clarke 67).
Subs Not Used: Trialist, Jonathan Stewart.
Ref: Brian Winter