The Honest Men sit second bottom of the cinch Championship after four fixtures. The midweek 2-0 defeat to Raith Rovers left them ninth with one point from 12.
Hopkin took charge of Ayr in March 2021, three months after leaving Greenock Morton.
In the transfer window, the former Scotland international signed four players he worked with at Cappielow, bringing in Markus Fjortoft, Aidan McAdams, Sean McGinty and Cameron Salkeld.
He exits just 48 hours before the club are set to host fellow strugglers Dunfermline Athletic at Somerset Park.
Former Hibs, Clyde and Dumbarton boss Jim Duffy was brought on to the coaching staff in the summer and will be in interim charge for the weekend’s fixture.
"Whilst naturally the terms of our discussions with David Hopkin remain confidential, we respect his views and would like to put on record our thanks for his efforts and wish him well for the future,” the club said in a statement.
“Training and match preparation will be co-ordinated by Jim Duffy, John Joyce, Dave Timmins and Derek Stillie over the next period and we very much appreciate their continued support.
“Our games over the next few weeks are of the utmost importance and we urge fans to continue to support us to get through what has been a challenging time at the Club between our Covid issues and recent results.
“We are looking forward to our fans cheering the team on to good results over the coming weeks and months.”