Head coach George Graham’s first match in charge at Mansfield Park produced a stirring performance by Hawick despite the defeat to the Scottish champions.
After early Ayr pressure, Hawick broke the deadlock in eight minutes when Dom Buckley made the initial break and Gary Munro raced in for the opening score and Ali Weir converted.
The lead was short-lived and the visitors were on level terms after Craig Gossman stormed over the line and Frazier Climo converted.
However, Hawick were determined and took the lead again, Buckley emerging with the ball from a group of players to score under the posts and Weir converted.
Climo pulled three points back on the restart with a penalty as Ayr played with more aggression, Stafford McDowall going over for a try and Scott Lyle converting for a 17-14 lead.
It was all Ayr as Lyle kicked a penalty and Hawick’s Rory Sutherland was yellow carded. Ayr’s forwards dominated and were rewarded with a penalty try.
Munro scored his second try, which Weir failed to convert, as Hawick stretched the Ayr defence with seven minutes left. But Ayr wrapped up a powerful performance with McDowall’s second try in the 80th minute.