Gala's bid perished in the first half as some unusually weak tackling let Ayr run in three tries, even though some good goal kicking kept the home side in touch. It was only late on that Gala struck back through their forward strength but it was not enough, and they lost by a single point, 33 to 34.
Ayr carried a bit more style behind the scrum and deserved to secure third place in the Premiership table, with a game against Hawick still to come. For Gala, whose supporters grieved over the loss until late in the evening, it was a case of repeating their season-long habit of a weak opening half followed by a dramatic recovery.
Coach George Graham, whose half-time sessions with his team have earned him a reputation as a straight-talking and effective motivator, however knew that this game had been an ask too far.
"It's hard to take but we didn't deserve to win," he said when he emerged from an emotional debriefing with his players. "We knew the Ayr backs were very dangerous and we just didn't play well enough in the first half. We needed to start the second half better but we conceded a penalty and a try before we came back with some character."
Gala were well served by their front five in the pack, with prop Ewan McQuillin, who had made a brief appearance for Edinburgh the previous night, showing up well. Veteran Samoan internationalist Opeta Palepoi nearly pulled it off for Gala with his 11th try of the season, and another long-serving Gala man, Tom Weir, was a useful replacement.
Stand-off David O'Hagan was in early form with his penalty kicks and notched four before the interval, hitting a post with another from far out.
He also served up one of Gala's more serious breakouts in the second half, with an interception taking him to within a few metres of the Ayr line. Gala's late try scorers were Rory Sutherland, Weir and Palepoi, with O'Hagan converting all three.
Ayr's good end-of-season form showed up in their crisp and effective backs, with tries from Craig and Kerr Gossman, as well as James Eddie, before the interval. After the break Ayr snuffed out Gala with a score from Ross Curle and another from Kerr Gossman, with Finn Russell kicking three conversions and a penalty.
Gala's losing bonus point took them tantalising close to their long-awaited win, but there were contrasting emotions at The Greenyards where Melrose eased through against a Currie side which had been hitting form lately.
As he has done all season Joe Helps gave Melrose command with his boot; the centre landing four penalties and two conversions.
Former Gala player and now Melrose coach John Dalziel felt for his former club when he talked of Melrose's victory, adding: "It's a great day for Borders rugby with two teams three miles apart battling for the championship."
Melrose director of rugby Mike Dalgetty also recognised how tough it would be for Gala to have missed out. "But we concentrated on our game and we've now had three titles in four years," he added.
The scenes of jubilation in Melrose contrasted with those at Netherdale, but the Gala supporters got together again yesterday after a night of reflection to make the draw for the annual sevens on April 5 and to prepare for this Saturday's RBS Cup semi-final against Glasgow Hawks.
Saturday also proved to be a big day for Hawick, who secured their top-flight status with a home win against Heriot's.