Super-sub Alex Williams scored a last-gasp equaliser only five minutes after coming off the bench to earn Ayr a money-spinning replay at Rugby Park a week on Tuesday.
This was a pulsating Ayrshire derby played in driving wind and rain with the result as expected going right to the wire.
Ayr had won the last four Cup meetings between these great Ayrshire rivals and were determined not to concede an inch with derby bragging rights at stake.
However it was Kilmarnock who took the lead in the ninth minute with a well-worked goal. David Fernandez played a short corner with Craig Bryson and when the ball eventually reached the centre, Manuel Pascali was left unmarked to score.
It took Ayr only three minutes to level. Ryan Stevenson did great work on the left and when his cross was flicked on by Bryan Prunty in steamed Dean Keenan to scored with a diving header.
Ayr should have gone ahead three minutes later, but Scott Walker's free header from a Chris Aitken free-kick slipped wide of the post.
A Grant Murray cross hit the outside of the post as Killie hit back, while a Willie Gibson cross landed on the roof of the net.
Killie made a strong start to the second half and were rewarded on 53 minutes when they took the lead. Gibson did the lead-up work and his through ball was steered home by Bryson.
Kilmarnock should have put the game out of sight on 70 minutes when they won a penalty after Martyn Campbell brought down Garry Hay.
Up stepped Allan Russell, but his low shot was superbly turned aside by the diving Stephen Grindlay.
Ayr threw on Williams for Alan Dempsie and went all out in a grandstand finish.
David Gormley blazed the ball over from an Aitken free-kick as the pressure mounted on the visitors' defence.
And with only seconds remaining, Somerset Park erupted when Williams found space at the back post to slam home an Aitken corner for a priceless equaliser.