Lock Damien Kelly and back Eddie McLaughlin were the try-scorers for the seasiders, while the accurate boot of James Noonan claimed four crucial penalties and an opportunist drop goal.
Ayr's rock-solid defence prevented Sonians from breaking through before the interval and they had to rely on a penalty double by Will Campbell to stay in the contest.
They did manage to find a gap in the second half as Stevie Lawrie was driven over, but they never threatened to steal the points.
In the only other surviving match in Premiership One, Melrose defeated Heriot's 33-15 at the Greenyards.
Glasgow Warriors' prop Kevin Tkachuk and his Canadian team-mates had victory snatched from their grasp in Bucharest as a last minute try and conversion from Romania saw them take the game 22-20.