Two late goals helped Ayr edge past fellow cinch Championship strugglers Arbroath in challenging conditions at Somerset Park.
Both sides battled heavy rain and wind and looked set to repeat the deadlock from their previous encounter at Gayfield just 10 days ago.
Jamie Murphy missed a chance to put the hosts in front from the penalty spot in the 55th minute when he hit the post and the rebound was pushed out for a corner.
Ben Dempsey finally made the breakthrough in the 74th minute with a brilliant long-range strike, and Logan Chalmers added the second from close range three minutes later to seal the win.