A late strike by Michael Moffat sealed a place in the First Division for Ayr in a dramatic Glebe Park play-off.
In blustery conditions, Brechin scored in 44 minutes when Jonathan Tiffoney's attempted back-pass to goalkeeper Alan Martin rolled into his own net.
Ayr's pressure paid off with 13 minutes to go when the ball broke to Mark Roberts and he rounded the impressive Craig Nelson and knocked the ball home.
Then in the 88th minute Moffat slammed the ball under Nelson for the winner.
Nelson almost gifted Ayr the opening goal midway through the first half when he failed to deal with a back-pass and Mark Robertson was inches away from scoring with a lob from 20 yards.
And it was from a wayward back-pass that Brechin took a 2-1 aggregate lead on the stroke of half-time when Tiffoney, just on for the injured Jim Lauchlan, tried to find Martin.
However, the keeper had come off his line to gather Martyn Campbell's wayward header in the strong wind and he was in no position to get back to clear.
Early in the second half David McKenna was through on Martin who saved bravely but spilled the ball and the home striker could not find the net with his second chance to score.
Ayr pressed again and Tiffoney set up Stuart Bannigan but he shot over the bar with 30 minutes to go.
Rory McAllister was fortunate not to be sent off when he pushed Tiffoney to the ground, but referee Crawford Allan allowed him to escape with a yellow card.
After Roberts had levelled the tie, Nelson made a stunning double save from Andy Rodgers and Scott McLaughlin as extra-time loomed.
But with three minutes to go the Honest Men scored the winner, Moffat's left-foot shot resulting in a rush of fans on to the pitch.
Brechin: Nelson, Cook, McBain, McLauchlan, Moyes, Janczyk (Kirkpatrick 89), Fusco (McLean 90), Molloy, McAllister, McKenna (Megginson 79), Redman. Subs Not Used: Scott, White.
Booked: McAllister, McLean.
Goals: Tiffoney 44 og.
Ayr: Martin, Lauchlan (Tiffoney 42), Smith, Malone, Campbell, McCann (Robertson 64), McLaughlin, Trouten, Moffat, Roberts, Bannigan (Rodgers 69). Subs Not Used: David Crawford, Easton.
Goals: Roberts 77, Moffat 88.
Ref: Crawford Allan