Ten-man Dundee shrugged off a red card for Eric Paton to stretch their lead at the top of the First Division to four points.
But Jocky Scott’s men were far from convincing as Ayr extended their unbeaten run to six games and stay above second-bottom Morton on goal difference.
Gary Harkins fired Dundee ahead with a sizzling 20 yarder but the lead lasted only three minutes.
On-loan Celtic full back Danny Lafferty drilled a free kick through a ruck of players to give Ayr a point.
Both sides took their time to get going in a largely dull first half, but Ayr looked the more threatening.
Former Dundee forward Tam McManus had the first real sight at goal for the Honest Men on 23 minutes when he met an Alastair Woodburn cutback but failed to test Rab Douglas with a weak shot.
But Ayr fell to a sucker punch as the half drew to a close and Dundee hit the front thanks to a wonderful finish from Harkins.
The midfielder picked up possession 20 yards out and unleashed a drive past Ayr keeper Craig Samson in what was Dundee’s first proper glimpse of goal.
But Ayr were straight off the canvas and charged up the field as the first half exploded in its closing stages.
Midfielder Steve Bowey burst forward and looked to be fouled inside the box by Brian Kerr’s challenge, but referee Brian Winter sparked outrage among home supporters by awarding a free kick on the edge of the box.
Dark Blues defender Maros Klimpl was booked after a shoving match with the referee in the scuffle which followed, but Ayr stayed cool and Lafferty stepped up to drill home the free kick.
It was Ayr who started the second half brightly as Ryan Borris went close with a 25 yarder.
The game was threatened by a host of stoppages by ref Winter, who carded a number of players.
Dundee were far from at their best but still looked a threat when they hit the box, and defender Gary MacKenzie should have restored their lead in the 63rd minute but blasted over.
But Dundee were given a mountain to climb with 14 minutes left when full back Paton picked up a second yellow to receive his marching orders for a late tackle on Borris.
However they still had chances to win it and both Leigh Griffiths and Harkins sent efforts over the bar in the final 10 minutes as the table toppers went for broke.