Top scorer Michael Moffat sent them on their way with a brace - his first from the penalty spot - to take his tally for the season to 24.
Kevin Kyle added a third before half-time and Ayr underlined their superiority with second-half strikes from Michael Donald and Alan Forrest.
It moved them to within three points of third-placed Stranraer who stuttered to a 1-0 defeat at Forfar Athletic.
Dale Hilson struck the only goal after 16 minutes, taking him into double figures for the season, and former Scotland goalkeeper Rab Douglas handled everything that came his way from Stranraer after that.
At the basement, Airdrieonians gained a valuable 1-0 win at Arbroath to keep their opponents at the foot of the table, one point behind the Lanarkshire club.
Jim Lister struck the only goal after 33 minutes, but both teams finished with 10 men.
Airdrie had Caolan McAleeer sent off and Arbroath had Richard Little red carded in injury-time.
Stenhousemuir beat Brechin City 4-2 in their mid-table clash at Ochilview. Darren Smith opened the scoring with a header and Sean Dickson added a second shortly afterwards following some slack Brechin defending.
Alan Trouten gave Brechin hope when he pulled a goal back before half-time, but the second half was only eight minutes old when Josh Watt netted Stenhousemuir's third.
Trouten netted a penalty to keep Brechin in touch, but John Gemmell added a fourth for Stenhousemuir 15 minutes from time to secure the points.