Hearts had to show composure and resilience to overcome a Scottish Cup scare before class told them and booked them a place in the fifth round.
Scott Bright, on loan from St Johnstone, had a huge scare six minutes after coming on as a first-half substitute with a wonderful goal.
Never mind the famous Hedge in Brechin, this was Close to the Hedge material for Hearts.
The Tynecastle team, however, showed a huge appetite for battle on what could have proved a grueling night.
Yan Dhanda, crucially, calmed nerves with an equalizer before the break.
Thereafter, Brechin was unable to match his previous levels of intensity or find answers to superior threats coming at them from all angles.
Scott Bright gave the hosts a surprise lead with a stunning long-range shot.
Yan Dhanda raised the level for Hearts shortly before half-time
Elton Kabangu scored a second-half double in his first start for the club.
Among them was Union Saint-Gilloise loan star Elton Kabangu, making his first start. The Belgian striker had a big involvement in the second, then opened his account for the club with a brace that allowed Hearts to pull away with confidence.
Paddy Cregg's Highland League leaders, out of action since December 28, kept their promise to make the night “uncomfortable” for the visitors from the start.
The home crowd's frenzy increased further when Fraser MacLeod broke the side netting in the 12th minute.
Chaos then ensued as City took the lead. Craig Halkett warned colleagues about his harrowing experience at the hands of Highland League rivals four years ago. Then a Championship team, Hearts, were eliminated by Brora Rangers.
The center half must have suffered terrible memories in the 23rd minute. Jamie McCart couldn't find a Hearts shirt when he tried to clear a low shot from the right.
Bright punished Neil Critchley's men with a rather impressive first shot from 30 yards. Craig Gordon, who was in the middle of the straight, had no chance and was beaten when the ball hit his left post.
Surprisingly, Bright was only in the park due to an act of self-harm by Euan Spark. The home team captain had started smartly by making some key defensive blocks.
However, midway into the Hearts half, he dived two feet off the ground onto Kabangu.
Attacker Kabangu joins Hearts on loan from Union St-Gilloise until the end of the season
Hearts manager Neil Critchley was delighted to emerge unscathed from a difficult tie.
If VAR had been involved, he would have left the field with a red card and Brechin would have been left with 10 men.
Instead, Grant Irvine booked him when he was substituted in agony clutching his shoulder, and 18-year-old Bright appeared.
Brad McKay was relieved to see Lenny Wilson deflect a Kenneth Vargas shot as Hearts pushed for an equaliser.
How desperate were the Premiership teams? Adam Forrester betrayed some of that with a penalty area simulation that earned him a booking. Dhanda refused to allow Brechin to take a lead at half-time.
The home defense stayed away from the diminutive schemer long enough for him to detect a flight path to the net. From 20 yards he produced a delightful shot past a blind Wilson and into the far corner for his first domestic goal for the club.
MacLeod and Dhanda were booked for a skirmish quickly after the leveller. Brechin simply had to keep his head as Hearts kept their cool after all the panic earlier.
Seven minutes into the second half, the visitors took the lead and never looked back.
Clever movement by the excellent Kabangu created space for a dangerous ball to the near post.
Former Hearts boy Kevin McHattie lunged to try and intercept. His errant touch swung towards goal and beat his own keeper and Vargas came to the line to try and claim the remains.
Local goalkeeper Wilson, under pressure, scratched a Vargas cross. Kabangu took advantage of the loose ball and had time to turn and fire home from 10 yards.
Wilson made an excellent save from Jorge Grant, but there was no way to keep the score down, with Kabangu hungry for more.
Substitute James Wilson intercepted a poor pass out of defense to slide towards Kabangu, whose deflected shot completed the scoring.