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.
Live Text Commentary
Full Time The referee blows for the end of the match.90:00 +1:41 Dismissal
Dismissal Gerard McLauchlan dismissed for second bookable offence.90:00 +1:40
Unfair challenge on Murray Davidson by Gerard McLauchlan results in a free kick. Marcus Haber restarts play with the free kick.89:23
Shot by Murray Davidson from deep inside the penalty area misses to the left of the target.87:50
Marcus Haber fouled by Michael Dunlop, the ref awards a free kick. Indirect free kick taken by Liam Craig.86:51
Free kick awarded for a foul by Craig Molloy on Murray Davidson. Free kick taken by Steven Anderson.85:28
Murray Davidson takes a shot.84:21 Substitution
Substitution David Robertson replaces Francisco Sandaza.83:41
Derek Carcary takes a shot.82:47 Substitution
Substitution Charlie King on for David McKenna.82:05
Jody Morris fouled by Craig Molloy, the ref awards a free kick. Indirect free kick taken by Alan Maybury.74:36
Murray Davidson takes a shot. Murray Davidson takes a shot.72:59 Substitution
Substitution David Crawford replaces Gary Fusco.71:36
The ball is crossed by Liam Craig. Inswinging corner taken by Liam Craig, clearance made by Paul McManus.68:53
Carl Finnigan takes a shot. Blocked by Bryan Hodge. Inswinging corner taken from the right by-line by Liam Craig.67:15 Substitution
Substitution Derek Carcary on for James Lister.63:42
Francisco Sandaza takes a shot. Save by Craig Nelson.61:04
The referee blows for offside against Paul McManus. Free kick taken by Peter Enckelman.55:20
Garry Brady fouled by Murray Davidson, the ref awards a free kick. Craig Nelson takes the free kick.54:21
David McKenna takes a shot.
Bryan Hodge produces a cross. Carl Finnigan is penalised for handball and concedes a free kick. Bryan Hodge takes the free kick.51:40
The ball is sent over by Carl Finnigan.50:32
The official flags James Lister offside. Indirect free kick taken by David MacKay.49:40
The ball is crossed by David MacKay.48:26
Inswinging corner taken by Garry Brady from the left by-line, Steven Anderson manages to make a clearance.48:19
The ball is swung over by Steven Anderson.47:27
Indirect free kick taken by Paul McLean.47:27 Booking
Booking Craig Molloy booked for unsporting behaviour.47:05 Booking
Booking Jody Morris goes into the book for unsporting behaviour.46:40
Free kick awarded for an unfair challenge on Craig Molloy by Murray Davidson.45:40
Assist on the goal came from David MacKay.45:40 Goal scored
Goal! - Francisco Sandaza - St J'stone 2 - 1 Brechin Francisco Sandaza scores a goal from deep inside the penalty box to the bottom left corner of the goal. St Johnstone 2-1 Brechin.45:25
The ball is sent over by David MacKay,45:01
The second half has started.45:00 +0:08 Half time
Half Time The first half comes to an end.44:34
Corner taken by David MacKay.38:34
Alan Maybury delivers the ball, Jody Morris challenges Craig Molloy unfairly and gives away a free kick. Craig Nelson takes the free kick.36:15
Craig Molloy gives away a free kick for an unfair challenge on Murray Davidson. Peter Enckelman restarts play with the free kick.35:31
Marcus Haber challenges Michael Dunlop unfairly and gives away a free kick. Indirect free kick taken by Craig Nelson.32:52
James Lister takes a shot. Peter Enckelman makes a save.31:47
Effort on goal by Francisco Sandaza from just inside the box goes harmlessly over the target.29:40
Craig Molloy challenges Marcus Haber unfairly and gives away a free kick. Free kick crossed left-footed by Liam Craig.28:29
The ball is sent over by Liam Craig.27:10
Jody Morris takes a shot. Clearance by Garry Brady.25:26 Goal scored
Goal! - Paul McManus - St J'stone 1 - 1 Brechin Goal scored by Paul McManus from just inside the area low into the middle of the goal. St Johnstone 1-1 Brechin.23:11
Liam Craig produces a strike on goal direct from the free kick. Liam Craig takes the inswinging corner, Headed effort on goal by Marcus Haber from just inside the box goes harmlessly over the target.23:11 Booking
Booking The referee shows Gerard McLauchlan a yellow card.23:09
Gerard McLauchlan challenges Francisco Sandaza unfairly and gives away a free kick.20:20
Craig Molloy challenges Murray Davidson unfairly and gives away a free kick. Indirect free kick taken by Jody Morris.19:19
Murray Davidson challenges Paul McLean unfairly and gives away a free kick. Free kick taken by Craig Nelson.17:58
Outswinging corner taken right-footed by Garry Brady from the right by-line, Close range header by Liam Craig goes over the crossbar.16:19
Centre by Liam Craig, Alan Maybury takes a shot. Clearance by Garry Brady.13:44
Michael Dunlop fouled by Marcus Haber, the ref awards a free kick. Craig Nelson restarts play with the free kick.11:55
Free kick awarded for a foul by Gary Fusco on Francisco Sandaza. David MacKay takes the indirect free kick.8:54
A cross is delivered by Gerard McLauchlan.8:33
Bryan Hodge takes a shot.5:35 Goal scored
Goal! - Murray Davidson - St J'stone 1 - 0 Brechin Murray Davidson gets on the score sheet with a goal from close range to the bottom right corner of the goal. St Johnstone 1-0 Brechin.4:48
Paul McLean challenges Liam Craig unfairly and gives away a free kick. Free kick taken by Liam Craig. Carl Finnigan takes a shot. Craig Nelson makes a save.1:21
David MacKay sends in a cross, blocked by Bryan Hodge. Corner from the right by-line taken by Liam Craig, Craig Molloy manages to make a clearance.0:00
The ref blows the whistle to begin the match.
Live data and text provided by our data suppliers