Dunfermline flexed their muscles to move into pole position in the race for promotion to the Championship.
They thought the trip to Somerset Park would be one of the more challenging of the first quarter of the season, and so it proved as a goal from Faissal El Bakhtaoui was all that separated them from the Honest Men.
Pars boss Jim Jefferies said: “It’s the sort of match we might have lost last season, so it shows we are moving in the right direction.”
Dunfermline made the early running with El Bakhtaoui darting into the box to force a fine save from David Hutton in the second minute.
Five minutes later the Ayr keeper was deceived by a swirling cross from Josh Falkingham and his blushes were only spared when El Bakhtaoui fired against the post.
Having weathered the early pressure, Ayr started imposing themselves, going close on 14 minutes when Brian Gilmour fired in a 22-yard shot that took a wicked deflection and flew just wide of Ryan Scully’s goal.
At the other end Gregor Buchanan rose above the home defence in the 22nd minute only to head Falkingham’s corner over the bar.
On 27 minutes Ayr’s Michael Donald sent in a teasing cross that was inches too high for the lurking Ryan Donnelly.
The opener came for the Fifers on the half-hour mark when Falkingham set up the impressive El Bakhtaoui, who hammered an unstoppable 22-yard shot into the roof of the net, with Hutton flailing helplessly.
Hutton prevented further damage when he palmed away Lewis Spence’s powerful 15-yard shot before the break.
United almost equalised just after the restart, when Peter Murphy’s net-bound header was palmed away by Scully.
El Bakhtaoui then went on a 40-yard run before firing his shot narrowly wide from 23 yards.
Ayr sub Craig Beattie sent in a shot that deflected off Ross Millen but landed in the side netting on 65 minutes.
The visitors looked just as likely to increase their lead, and almost did so through El Bakhtaoui, who had Hutton in action again midway through the second half.
Dunfermline’s substitution of one former United player, Michael Moffat, for another, Andy Geggan, did little to improve the mood of home supporters, whose final hopes of an equaliser ended when Murphy’s shot was brilliantly clawed round the post in the dying minutes.