Wallace put Dunfermline 3-2 up on 69 minutes and Jordan Moore wrapped up the scoring five seconds into injury time with a close-range effort.
The win means that Dunfermline remain three points clear in second ahead of Stranraer, who eased past 10-man Brechin City 3-0 at home to stay third.
Airdrieonians are rooted to the foot of the table after losing 3-1 at home to East Fife despite taking the lead early in the first half.
Lewis Coult put the Diamonds ahead in the 18th minute with a close-range shot, but an own goal from Gregor Buchanan saw East Fife restore parity before half time at the Excelsior Stadium in Airdrie.
Ross Brown headed home Stephen Hughes's delivery on 70 minutes and the latter himself secured the points for the visitors with a free kick six minutes later.
Elsewhere, Forfar Athletic drew 1-1 with Arbroath at home and the evening kickoff between Stenhousemuir and Rangers was called off two hours before it was scheduled to get underway due to structural damage to a temporary stand at Ochilview Park.
Results in full: Airdrieonians 1-3 East Fife, Ayr 2-4 Dunfermline, Forfar 1-1 Arbroath, Stranraer 3-0 Brechin, Stenhousemuir P-P Rangers