Second-half goals from Gareth Wardlaw and Chris Robertson sent Ayr up to fourth in the table.
It was also United's fourth win in five as they continued their recent rich run of form.
After a dire first half of few chances the game came to life after the restart.
Wardlaw fired Ayr in front just three minutes after the break when he pounced on Robertson's knock on inside the box.
Forfar battled hard and Darren Gribben wasted a great chance to level when he headed straight at Mark McGeown from six yards.
Ayr made them pay when Robertson charged clear to slam home the second after being sent through on goal by Craig Conway.
Forfar clawed their way back into contention with a late Steven Bonar goal when he tapped home from close range.
The Loons piled everything forward in the closing minutes but to no avail as Ayr held firm.