Defender Kyle McAusland scored an 88th-minute winner at East Fife to become Ayr's unlikely hero in a 3-2 victory.
The two bottom-placed sides were both looking for their first league win of the season, and it was the hosts who took the advantage after five minutes, Jamie Pollock finding the bottom corner with a low drive.
The Honest Men were back on level terms just four minutes later after Michael Moffat set up David Sinclair for a simple tap in.
Sinclair was then on hand to score his second of the afternoon and give the visitors the lead with a clinical left-footed finish after 34 minutes.
Seven minutes from time, Robert Barr let fly with a stunning 25-yard volley which found the top corner to give what the Fifers believed to be a late equaliser.
But caretaker manager Gordon Chisholm's side were unable to hold onto their point as McAusland headed in Sinclair's corner late on to give Mark Roberts' team a last-gasp victory.