Ryan Thomson was the hero for the hosts, nodding home a header on the hour mark following superb work on the flank by Alex Whittle to finally break the deadlock after a dominant display from Jim Jefferies' youthful side.
With the gate receipts split in this competition, February's trip to Ibrox will provide a welcome injection for the fan-owned Fifers. While such a prize is sought after by all clubs, particularly those outwith the top flight, it is a pertinent boost to the coffers of Dunfermline as they attempt to rise from the ashes of administration.
In truth, the score did little to flatter the hosts and, if not for excellent work from goalkeeper David Hutton, they might have posted a far more handsome victory. Hutton spread himself superbly in the first period to parry a point-blank effort by Thomson wide of the post after Ryan Wallace had sent him clear on goal. Another low save from a Thomson effort ensured the score remained level before the striker finally made his mark after the break.
Kevin Kyle, who cut a lonely figure up front for the visitors for the most part, flashed one header over the bar from a whipped Michael Moffat delivery as Ayr attempted to find a way back into the game in a late rally. And Moffat saw the visitors' best chance of the game superbly saved by Ryan Scully, ensuring Dunfermline progressed to the last 16.