Alan Forrest's last-gasp winner was enough for Ayr as they beat Queen's Park 2-1 in the Ramsdens Cup first round.
Michael Moffat and Craig Malcolm both went close for the visitors in the opening stages but neither could find a way past Spiders stopper Blair Lochhead.
The hosts soon took control of the game and were ahead just before the half-hour mark. Anthony Quinn netted from the penalty spot after Martyn Campbell was adjudged to have handled the ball inside the area.
Bernard Coll could have added a second shortly after but blazed his effort wide after some good build-up play.
However, the Honest Men were level shortly after the restart when Moffat poked home Campbell's pass.
With the game seemingly heading for extra-time, substitute Forrest popped up a minute from time finishing from close range after Adam Hunter's long throw caused problems in the area.