Hamilton slipped to their first defeat of the season as Ayr went top of the Premier Sports Cup Group E table with a slender win at New Douglas Park.
Cameron Sekeld's 27th-minute strike was enough to take the points back to Somerset Park and, for their first half performance, it was merited.
It wasn't a great homecoming for the Accies supporters who were allowed to return to their stadium in well over a year.
Hamilton, who came more into the game in the second period but couldn't trouble keeper Charlie Albinson too much, now must beat Albion Rovers here on Saturday to be sure of progression.
Accies looked decent on the attack in the first period, but never really threatened Albinson.
The visitors, however, frequently looked dangerous on the attack, and Tomi Adeloye in particular looked lively.
While Accies had much more of the ball after the interval, they didn't do enough with it.
Accies head coach Brian Rice made two changes to the side that beat Falkirk on Saturday, with captain Brian Easton coming in for Shaun Want, and Kyle Munro replacing David Noyo.
David Hopkin went with the same Ayr side that beat Edinburgh City 3-0 last time out.

Ayr made a lively start and Michael Hewitt hit a low effort towards the bottom right corner, but it was a comfortable first save for Joe Hilton.
Accies created a decent move in four minutes which ended with Ronan Hughes picking out Munro, but his shot was well blocked by defender Jordan Houston.
Hamilton went close in 15 minutes when Munro's header angled from a corner on the left was cleared off the line at the left post.
But Ayr took the lead in 27 minutes when Cameron Sakeld picked up a loose ball just outside the box and slammed a low shot into the left corner.
Another slack ball in 32 minutes put Tomi Adeloye through on the left, but Joe Hilton recovered superbly to take the ball, and cleanly.
Accies tried to strike back and Kieran MacDonald made his way down the left flank, but fired low across goal and out for a goal-kick.

Adeloye was stopped in his tracks in 33 minutes, with referee Bobby Madden ruling the foul was on the edge of thee box, rather than awarding a penalty.
Aaron Muirhead's free kick took a deflection off the wall and bounced just wide for a corner on the left.
Accies had another chance in 38 minutes but Munro got under Ronan Hughes' corner and headed well over.

Munro had a go again in 55 minutes with a long-range effort that nearly squirmed under keeper Albinson, but he grabbed it before it slipped over the bye-line.
Lewis Spence had a curling effort from distance in 61 minutes, but it flew high and wide of the left post.
MacDonald went on a run two minutes later, but blasted over from just outside the box.
Ayr had been relatively quiet for a spell but Pat Reading fired past the right post in 74 minutes.
Sub Adam McGowan nearly set up an equaliser in 90 minutes but his cross from the left was glanced past the far post by David Moyo.
HAMILTON: Hilton, Stirling, Hamilton, Easton (McGowan, 88), MacDonald, Mimnaugh, Spence, Hughes, L. Smith, C. Smith (Moyo, 74), Munro.
Subs (not used): J. Smith (GK), Want, Redfern, Meikle, Gaffney, McGinn.
Booked: Spence (84)
AYR UNITED: Albinson, Houston, McGinty, Baird, Reading, McKenzie (Miller, 88), Muirhead, Murdoch, Hewitt (Chalmers, 70), Sakeld, Adeloye (Fjortoft, 68).
Subs (not used): McAdams (GK), Ecrepont, Bilham, Jeanes, P. Smith.
Referee: Bobby Madden.
Follow Lanarkshire Live Sport on Twitter via @LanLiveSport, like us on Facebook or find us on Instagram for the latest sports news, pictures and video.