Dipo Akinyemi's double and a late penalty from Ben Dempsey took Ayr United six points clear of second-placed Morton at the top of the Championship, with a narrow win over Hamilton.
Morton boss Dougie Imrie - an Accies legend - was in the stadium to see the win, leaving his side with it all to do against Partick Thistle tomorrow.
Akinyemi bagged his 12th goal of the season in four minutes, and added to that 65 minutes later, after Steve Lawson had levelled for Accies from the spot.
Hamilton again levelled, through a Finn Ecrepont own-goal, only for Dan O'Reilly to pull down Andy Kirk and concede a stupid penalty late on.
That was a bit harsh on an Accies side that was possibly denied a first-half equaliser through Jean-Pierre Tiehi, due to an unsighted linesman.
But while Hamilton dominated much of the game, Ayr always looked threatening coming forward, particularly through Akinyemi.
The big striker got Ayr off to the perfect start after just four minutes, scoring his 12th goal of the season.
It was almost all Accies after that for the remainder of the half, with some controversy as they were denied what looked like a decent penalty shout, and a goal that looked to have crossed the line.
However, Hamilton continued to struggle up front, and their defending left a lot to be desired.
Ayr had chances to stretch their lead, particularly through Akinyemi, while Accies looked shaky at the back.
However, Accies started the second half much better and Lawson had them level within five minutes, from the spot.
However, he blasted a shot over the bar and Ryan fired past the post as they again struggled to take their chances, and Ayr bagged their second in 69 minutes, with a thunderous finish from Akinyemi.
Ecrepont bundled in Doyle's cross to draw level again, but O'Reilly's penalty gave Dempsey a chance to win it for Ayr.
Hamilton boss John Rankin made six changes from the side that beat Rangers 'B' 3-0 in the SPFL Trust Trophy third round on Tuesday night. Goalkeeper Ryan Fulton replaced Jamie Smith, and Steve Lawson, Scott Martin, Andy Ryan, Andy Winter and Jean-Pierre Tiehi came in for Ferguson Owens, Lewis Latona, Lewis Smith, Jonny Ngandu and Ryan One.
Ayr United gaffer Lee Bullen made two changes from the side that drew 1-1 with Morton on Saturday, as Paddy Reading came in for Brad Young and Paul Smith replaced Frankie Musonda.
Accies created the first move inside two minutes when Ryan played a neat one-two with Winter that took him into the box, but Charlie Albinson safely grabbed the ball at his feet.
However, a slack pass from Ryan then sent Akinyemi down the left and he cut inside before slamming the ball into the bottom right corner.
Ayr's Andy Murdoch was yellow carded for a foul on Scott Martin in 10 minutes that looked like it was inside the box, but a free kick outside was the decision.
The free kick was touched by Dario Zanatta to Ryan, but his shot was deflected past the right post.
From Reegan Mimnaugh's corner, Michael Doyle's header was cleared off the line by Akinyemi.
Martin sent a snap-shot inches past the left post from wide on the right in 15 minutes as Accies tried to draw level.
Ryan was then put through on goal, but Albinson made a good block with his chest to deny him and Accies were forced to settle for another corner.
Mimnaugh's set-piece wasn't properly cleared, with Dan O'Reilly's shot blocked before Steve Lawson fired the rebound over the bar.
Lawson lost out to Jayden Mitchell-Lawson in 20 minutes, with his low shot touched round the left post by Fulton.
Accies thought they had scored in 24 minutes when Zanatta set up Tiehi, but his shot cannoned off the bar, though TV pictures appeared to show that it was over the line. However, no goal was given.
However, Accies pulled level five minutes into the second half when McG9inty tripped Winter inside the box and Lawson stepped up to smash the penalty into the bottom left corner for his third goal of the season.
He had a chance to put Accies ahead shortly after that, but blasted over following a good move.
Lawson then turned provider for Ryan in 61 minutes, but his shot on the turn was comfortably saved by Albinson.
However, Ayr regained their lead in 69 minutes when sub Finn Ecrepont set up Akinyemi, who smashed the ball high into the net for his 13th goal of the season.
But Accies conceded a penalty shortly afterwards when O'Reilly pulled down Alex Kirk, and Ben Dempsey stepped up to smash the penalty into the bottom left corner.
HAMILTON: Fulton, Lawson, Doyle, O'Reilly, Shiels, Martin, Mimnaugh, Zanatta One, 87), Winter, Ryan (L. Smith, 79), Tiehi.
Subs (not used): J. Smith (GK), Easton, Virtanen, Brown, Owens, Latona, Morgan.
Booked: Lawson (55), Doyle (90+1)
AYR UNITED: Albinson, McAllister (Ecrepont, 65), Kirk, McGinty, P. Smith (Ashford, 46), Mullin (McKenzie, 85), Dempsey, Murdoch, Reading, Mitchell-Lawson (O'Connor, 54), Akinyemi.
Subs (not used): McAdams (GK), Young, Bilham, Bangala, Bryden.
Booked: Murdoch (10), McAllister (55), Reading (72), Dempsey (87)
Referee: Matthew MacDermid.
Attendance: 1677.
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.