Dunfermline climbed to fourth in the Championship thanks to a 16th goal of the season from the prolific Kevin Nisbet.
The striker, who scored four in a 5-1 hammering of bottom side Partick Thistle on Saturday, maintained his rich seam of form with a trademark header from Greg Kiltie’s cross midway through the second half.
The goal caught Ayr cold as they returned to action after a 24-day lay-off and they looked ring-rusty after such a long spell on the sidelines.
Manager Mark Kerr was able to name himself on the bench for the first time since succeeding Ian McCall in mid-October after finally shaking off an injury.
Dunfermline made two changes from the team that routed the troubled Jags. Skipper Paul Paton missed out through injury while Andy Ryan dropped down to the bench with Harry Cochrane and Kyle Turner drafted into the starting lineup.
A minute’s silence was impeccably observed before kick-off in memory of former Ayr chairman Bill Barr who led the Somerset Park club to their first-ever national cup final in 2002 when they lost 4-0 to Rangers in the CIS Cup.
Incredibly, Gordon Dalziel’s team were back at Hampden only six days later, on this occasion losing 3-0 to Celtic in the Scottish Cup semi-final.
The action was slow to heat up with only a stinging challenge by Cochrane on Ayr skipper Ross Docherty bringing the crowd to life.
The home team almost gift-wrapped their opponents a dream start when Daniel Harvie’s poor clearance forced them to concede a corner.
Fortunately for Ayr, Turner’s poorly struck flag kick was as wayward as Harvie’s delivery.
On-loan Stephen Kelly had Pars goalkeeper Cameron Gill scampering across his line when he struck a free-kick from 25 yards into the side netting.
Ayr came close again after 21 minutes when Craig Moore fired in a low shot, which the diving Gill parried before the ball was hacked clear.
Nisbet underlined his threat when he rose to meet a cross from Lewis Martin. However, the 22-year-old striker, who had a previous loan spell at Ayr, directed his header straight at Ross Doohan who made a comfortable save.
Nisbet sensed another opening when he ran onto a through ball but Sam Roscoe’s timely intervention saved the day for Ayr at the expense of a corner.
The Fifers began to step up the pressure and it took a good save from Doohan to deny Turner’s volley from Ryan Dow’s cross.
Ayr replied with a Kelly corner which flew straight to defender Aaron Muirhead who lifted his shot over the top to let the visitors off the hook.
The Pars restarted with Josh Edwards replacing injured skipper Lee Ashcroft and they almost made the breakthrough after 55 minutes. Aaron Comrie did the spadework with a run and cutback but Doohan got down well to block from Turner.
The visitors were knocking on the door and it was little surprise when they made the breakthrough.
Kiltie supplied the perfect cross for Nisbet, who didn’t need to break his stride as he buried his header into the bottom corner.