AYR staged a remarkable second-half recovery to score five tries and secure the crucial bonus point with a sterling performance.
Playing with the strong wind, Ayr showed their intentions early on as a break by Frazier Climo set up the opening try for Robbie Fergusson in only six minutes and Climo converted.
However, the league’s bottom club dug in 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 disrupted the Ayr scrum as the visitors battled to restore their authority.
Selkirk refused the offer of a penalty in front of the posts, and when the ball was quickly switched to the left, Josh Welsh gave Selkirk an 8-7 lead at half-time with a try in the left-hand corner.
Banks increased the lead early in the second half with his second penalty before Climo hit the post at the other end. Ayr restored their lead with a try by Grant Anderson and Climo converted.
Ayr showed their powerful presence as Ross Curle scored and Climo converted and Curle’s second try in the dying minutes, with Andrew Renwick shown a yellow card, sealed the bonus point before Fergusson scored again and Curle converted.