A SECOND-half Bilel Mohsni double ensured Rangers narrowly avoided dropping points in SPFL League One for just the third time this season.
His stunning brace means the Ibrox club are now just two games away from going through their entire league campaign unbeaten.
Ally McCoist's side take on Stranraer at home on Saturday - when they will be presented with the third tier trophy - and Dunfermline away seven days later.
If the Gers, who have not lost in 34 league outings, can avoid defeat in their final two fixtures they will create a little piece of history.
But the Light Blues will have to perform better, far better, than they did against Ayr to do so. They survived a serious scare last night and were lucky to triumph.
McCoist made one change to the Rangers side that had thrashed Stenhousemuir at Ochilview three days earlier.
He dropped Kyle Hutton and brought back Arnold Peralta.
Ayr are fourth in the third tier table and are pushing for a play-off spot. In the opening stages of the game they looked the far hungrier of the two combatants.
The best scoring chances of the first half fell to the home team. Stevie Smith and Fraser Aird linked well to tee up Jon Daly for a shot at goal in the 19th minute.
Daly should have taken his tally for the 2013/14 campaign to 26. But the Irishman, who has lacked a definite sharpness for several weeks, shot over the crossbar.
Cammy Bell, now fully recovered from the concussion that ruled him out of the Scottish Cup semi-final with Dundee United, did well to keep his side on level terms on the half-hour mark.
Michael Donald was alert to a neat flick-on from Scott McLaughlin and broke clean through on goal.
The goalkeeper came off his line quickly to block the striker's shot.
McCoist's unhappiness at his side's disjointed performance in those opening 45 minutes was obvious when he punched the roof of his dugout in frustration. The Gers manager was, however, punching the air in jubilation early in the second half when his charges edged in front with the simplest of strikes.
Fraser Aird sent a corner into the Ayr penalty box in the 53rd minute and Mohsni rose unchallenged to nod a downward header past goalkeeper David Hutton into the net.
It was the French-Tunisian centre-half's 11th goal of the season - a fine return for a player in his position - and he celebrated it in typically exuberant fashion.
But Alan Forrest, younger brother of Celtic and Scotland star James, hit an equaliser after some slack play by both Richard Foster and Peralta, in 79 minutes.
McCoist immediately threw on Nicky Clark for Peralta and Calum Gallagher for Dean Shiels. His substitutions had the desired impact.
Clark had his header from a Nicky Law chip saved by Hutton in the 82nd minute.
Mohsni, though, followed it up and prodded home from a few yards out to seal victory.
In his programme notes, club chief executive Graham Wallace alluded to what would be contained in the findings of his by now fabled 120-day business review on Friday.
He wrote: "We have completed our review and the board has been engaged in recent weeks in developing the proposed future strategy to equip the club to be competitive once again at the top of Scottish football.
"We will be issuing an update on the business review later this week to give Rangers supporters more insight into the current position of the club and, more importantly, our future aspirations."
With bold references to "the top of Scottish football" and "future aspirations" it was a decidedly upbeat message from the man upon whose shoulders so much rests.
It will have helped to increase anticipation and curiosity among Light Blues fans - which were sky high as things were - about what the review will contain.
But Wallace, the former Manchester City chief financial officer, will earn every penny of his salary, whatever it may be, if he has succeeded in mapping out a feasible route forward.
For a large section of the Rangers support remains on course to withhold their season ticket money in a trust fund until security is granted over Ibrox and Murray Park.
The Govan stadium was, understandably given that it was a meaningless fixture on a miserable Tuesday night, probably less than half-full against Ayr United last night.
Nevertheless, the Union of Fans - an umbrella group comprising six supporters' organisations - still distributed leaflets outside the ground before kick-off outlining their aims and concerns.
"The so-called review is a diversion designed to buy the board time," the flyers read. "This board have shown themselves to be incapable of running the club."
It was a reminder of the deep unease that exists about the future intentions of those who hold power at Rangers and the difficulties Wallace faces bringing harmony to the club.
Trackside and programme advertising, meanwhile, urged those supporters in attendance to renew their season tickets and protect the legacy of the club.
Just how many will do so, and whether their funding will be enough to sustain Rangers in the Championship next season, remains to be seen.