A goal in each half from Cowdenbeath condemned Ayr to a fifth straight league defeat.
On-loan Hibs goalkeeper Alistair Brown needlessly brought down Scott Dalziel for a 13th-minute penalty which Liam Buchanan dispatched confidently.
Ayr tried to fight back and Gareth Wardlaw sent two efforts just wide while Chris Robertson nodded past the post from a David Dunn corner.
But the Fifers sealed victory when Pat Scullion slammed home a 25-yard drive.
Ayr: Brown, Forrest, Campbell, Brian Reid (Vareille 78), Lowing, Stevenson, Weaver, Dunn, Waddle, Robertson, Wardlaw.
Subs Not Used: Pettigrew, Templeton, Hyslop, Johnson.
Booked: Stevenson, Lowing, Campbell.
Cowdenbeath: Hay, Guy, Hill, Fusco, Ellis, Docherty, Hannah, Davidson (Fotheringham 66), Patrick Scullion, Buchanan, Dalziel (Clarke 74).
Subs Not Used: Marshall, Weir, Allison.
Goals: Buchanan 13 pen, Patrick Scullion 72.
Ref: W Collum.