Ross Robertson struck late to claim Ayr United a home victory over Raith Rovers at Somerset Park.
Michael Moffat fired the hosts ahead in the 23rd minute following Michael McGowan's cross.
Raith's Ross Callachan was sent off for violent conduct but the visitors rallied and levelled through Joe Hamill's sweeping shot on 34 minutes.
But Ayr snatched all three points when Robertston rose in injury time to head home James McKernan's centre.
Ayr: Cuthbert, Duff (Ross Robertson 86), Smith, John Robertson, Malone, McGowan, Geggan, McKernan, Moffat, Wardlaw, Roberts (Tiffoney 72). Subs Not Used: McWilliams, Burke, Armstrong.
Booked: Ross Robertson.
Goals: Moffat 23, Ross Robertson 90.
Raith: McGurn, Donaldson, Murray, Hill (Dyer 75), Ellis, Williamson, Walker, Callachan, Hamill, Baird, Brian Graham. Subs Not Used: Laidlaw, Reynolds, Walls, Colin Wilson.
Sent Off: Callachan (28). Booked: Donaldson, Williamson, Baird.
Goals: Hamill 34.
Ref: Matt Northcroft