St Johnstone overcame Brechin City to book a spot in the fifth round of the Scottish Cup.
Murray Davidson's rebound shot gave the Scottish Premier League side the lead early on.
But Second Division Brechin battled back and levelled through Paul McManus on 26 minutes.
Francisco Sandaza edged Saints back into the lead in the opening seconds of the second half and Brechin were unable to find a second equaliser.
With these sides having met in last season's competition in a tie settled when St Johnstone won a replay at McDiarmid Park by a single goal, another close contest ensued.
However, Saints struck an early blow to Brechin's chances of causing a cup shock when Davidson netted.
Visiting goalkeeper Craig Nelson could only parry Karl Finnigan's shot from the edge of the box and Davidson applied a tap-in to the rebound to open the scoring.
Brechin responded with David McClune having two efforts blocked as Saints struggled to clear their lines.
Marcus Haber headed wide from Finnigan's pin-point cross and the former glanced another effort wide following good work by Liam Craig.
And Saints were the victims of their own undoing moments later as Jody Morris's headed back-pass was seized upon by McManus, who rounded goalkeeper Peter Enckelman before slotting into the empty net.
A long-range effort by Sandaza did not overly trouble Nelson as the first half wound down.
But Sandaza did register just after the break, the Spaniard being found in space by Dave MacKay's cross and slamming the ball into the left-hand corner.
Brechin continued to cause their hosts problems and had a penalty claim turned down when Garry Brady's shot appeared to strike the hand of Steven Anderson.
Enckelman was then forced to block a David McKenna effort.
Substitute Derek Carcary was unable to test Enckelman as time began to run out for former Saint Jim Weir's side.
Finnigan headed just wide from MacKay's cross in injury time but it mattered little with St Johnstone preserving their lead.
Sorry, we were unable to load match stats, please try again.