Ross Robertson netted a late winner as Ayr twice came from behind to beat Dundee 3-2.
The visitors took the lead in the 14th minute when Ryan Conroy fired home from close range.
Steven Milne came close to doubling the advantage just after the half-hour mark but could not keep his effort down.
The hosts rarely looked like threatening and failed to create a single opportunity in a poor first half.
Nicholas Riley rattled the bar just after the restart and the game looked to continue in similar fashion until the Honest Men began to press.
They levelled things just after the hour-mark when Keigan Parker fired a superb free-kick beyond Rab Douglas.
But the visitors soon restored their lead when Milne headed home from close range in the 70th minute.
Keigan produced a stunning overhead kick six minutes from time to level again before Robertson pounced from close range to snatch the win.