Not for the first time this season lowly Selkirk showed that they can match up to the Premiership big guns, for a spell at least.
Having been 11-7 up until 10 minutes into the second half the Selkirk defence crumbled however with the league leaders staging a recovery worthy of their lofty position to score five tries, overall, and secure the crucial bonus point.
Playing with the strong wind in their favour, Ayr showed their intentions early on when Robbie Fergusson touched down and Frazier Climo converted.
Selkirk dug deep and pulled three points back after George Hunter was sent to the sin-bin for a push and Rory Banks kicked the penalty.
The Selkirk pack continued to disrupt the Ayr scrum as the visitors battled to restore their authority and, after refusing the offer of a penalty kick in front of the posts, the ball was quickly switched to the left and Josh Welsh gave the hosts an 8-7 lead at half-time with a try in the corner.
Banks increased the lead early in the second half with his second penalty but Ayr restored their advantage with a try by Grant Anderson converted by Climo.
Ross Curle scored two more tries with Fergusson adding another and Curle converting.