Alan Trouten's shot found the net off the inside of a post to give Ayr the lead.
And, in the second half, Stranraer goalkeeper Cameron Belford failed to clear a passback and Michael Wardrobe was left with a simple tap-in.
The visitors pulled one back through Ryan Thomson's header but Ayr held on.
Ayr United booked their place in the promotion play-offs after holding on for a win at home to Stranraer in Scottish League One.