Goals from Graham Hay, Jonny Brown and Alan Trouten were cancelled out by Jon Daly, Bilel Mohsni and Nicky Law.
The decisive goal came from Nicky Clark as Rangers claimed nine league wins on the bounce.
But the game started in disastrous fashion for Ally McCoist’s side as they fell behind after five minutes when Trouten delivered a corner into the box where skipper Hay was waiting to head home unmarked.
City then doubled the lead just three minutes later, Brown firing home a free-kick on the edge of the area into the back of the net.
But Gers rallied and pulled goal back after 26 minutes when Daly raced onto a long ball before calmly slotting past Graeme Smith.
Lee McCulloch should have scored from close range but instead, it was Brechin who were celebrating again after 35 minutes.
Law was unable to clear a poor Richard Foster pass, allowing Trouten to pounce and drill home from the edge of the area.
Rangers did look more threatening after the restart and Mohsni duly poked home an Ian Black free-kick from a couple of yards out.
Rangers were back on level terms when what appeared to be a cross, rather than a shot, from Law found its way into the back of the net.
Substitute Bobby Barr could have restored Brechin’s lead but he hooked wide when he should have scored and Craig Molloy then rattled the crossbar with a header as City pushed for the winner.
But the points went to Rangers with six minutes to go when David Templeton’s cross found Clark who left Smith with no chance as he headed home.
There was further misery for City when Trouten was dismissed at the end for a pull on Templeton on a day when referee Craig Charleston also brandished 11 yellow cards.