Ryan Wallace scored twice as Dunfermline demolished Ayr.
The visitors took the lead in the second minute when Michael Moffat fired in from the middle of the box.
The Pars drew level in the 21st minute when Wallace scored from the penalty spot after Adam Hunter had fouled Andrew Geggan in the area.
Dunfermline went ahead 10 minutes later thanks to Alex Whittle's sensational left-footed strike before Geggan made it 3-1 from the right of the box shortly after.
The hosts made it 4-1 five minutes before the break when Joshua Falkingham found the top corner of David Hutton's net.
Ayr almost reduced the deficit in the 49th minute when Jackson Longridge tried his luck from distance, but his effort hit the bar.
Instead the home side extended their lead in the 65th minute when Wallace fired in from the edge of the box.
Dunfermline: Scully, Millen, Johnston, Morris, Whittle (Young 66), Byrne, Husband (El Bakhtaoui 73), Geggan (Ryan Thomson 80), Falkingham, Wallace, Robert Thomson.
Subs Not Used: Moore, Ferguson, Smith, Goodfellow.
Goals: Wallace 21 pen, Whittle 31, Geggan 39, Falkingham 41, Wallace 65.
Ayr: Hutton, Hunter, Pope, Lithgow, Donald, McGowan (Roberts 45), Robert Crawford (Kyle 75), McLaughlin, Forrest (Longridge 45), Moffat, Malcolm.
Subs Not Used: Wyllie, Shankland, William Muir, Marenghi.
Booked: Hunter, Robert Crawford, Longridge, Kyle.
Goals: Moffat 3.
Ref: George Salmond