Derek Holmes grabbed the only goal for league leaders Queen of the South and despite a spirited second-half barrage from Ayr the Doonhamers grabbed a vital three points.
Holmes rose at the back post to head home a cross from Stephen McKenna after 20 minutes.
Queens' David Lilley flashed a header wide soon after, while Ryan Borris nodded into the side netting for Ayr.
Ayr came out fighting in the second half with Mark Roberts and Ryan Stevenson going close.
Queens with Lilley outstanding held out for a vital three points to remain top of the first Division.
Queens MAD Man of the Match - David Lilley - Was outstanding in the second half as Ayr had a real go at us.