New manager Sandy Clark must already realise the size of the task he has taken on in trying to build a Berwick revival.
After holding Ayr for 85 minutes, largely due to the accomplished Gary O'Connor, the defence simply collapsed.
Stewart Kean snatched the winner in injury time, left unmarked to steer Stuart McGrady's pass into the net.
In the three minutes before that sickening blow Berwick escaped twice when Dougie Ramsey failed to connect with the goal at his mercy, and Kean headed wide from a McGrady cross.
Until then Berwick had looked well organised and solid with Mark Cowan and Robbie Horn working hard, but they have yet to keep a clean sheet this season, and Clark now takes on a team at the foot of the table and with five successive home defeats.
McGrady and Darren Henderson established midfield dominance for Ayr in the second half and O'Connor made some great saves.
Berwick played well in the first half with Darren Smith impressive, but he faded badly. Gareth Hutchison had one shot brilliantly saved by Ludovic Roy and had a goal disallowed, but they made little advantage of the conditions and eventually paid the penalty.
An experienced campaigner, Clark, will need to find a cure to Berwick's problem.