The Second Division outfit were more than a match for their SPL opponents throughout and levelled through Paul McManus after Murray Davidson's opener.
Francisco Sandaza netted the winning goal 30 seconds into the second half and despite demonstrating great determination to force a second equaliser, City could not find a way through.
The hosts began the match on the front-foot and they were rewarded with the opening goal after five minutes.
Craig Nelson in the Brechin goal could only parry Karl Finnigan's shot from the edge of the box and Murray Davidson was on hand to tap home the rebound.
Brechin responded in a positive fashion and David McClune had two efforts blocked as the home defence struggled to clear the danger.
The difficult surface was proving problematic for both sides with a series of mis-controls becoming the pattern of a scrappy opening to the game.
St Johnstone passed up an excellent chance to double their lead when Marcus Haber connected with Finnigan's pin-point cross but the Canadian striker headed wide of target.
Haber had another good opportunity after 24 minutes but again glanced wide after good work by Liam Craig.
A horrendous mix-up in the home defence led to Brechin grabbing an unexpected equaliser. Jody Morris' headed back-pass was seized upon by Paul McManus who rounded Peter Enckelman and slotted into the empty net.
After conceding the home side appeared to be shell-shocked and Sandaza's long-range effort was as close as they came to regaining their advantage in the firs -half.
After enduring a frustrating opening 45 minutes, it took the SPL side only 30 seconds to grab the lead in the second half.
David MacKay's cross found Sandaza in space and the Spaniard slammed the ball into the bottom left-hand corner of Nelson's goal.
Despite falling behind for the second time in the match, Brechin continued to press and had a good shout for a penalty turned down when Garry Brady's shot appeared to strike the hand of Steven Anderson.
David McKenna then forced Enckelman into a good stop after 54 minutes.
City boss Jim Weir replaced the tiring James Lester with Derek Carcary and then David Crawford for McClune in a bid to increase the pressure on the home defence.
Carcary had a decent opportunity with the clock running down but he could not force Enckelman into making a save.
Deep into injury-time Finnigan almost put the tie beyond doubt, but headed inches wide from MacKay's delivery.