Motherwell survived a storming second-half comeback by Queen of the South to escape into a Tennents Scottish Cup quarter-final against Inverness Caledonian Thistle.
An early penalty by Derek Adams and a first-half double by Alex Burns - his first goals of the season - appeared to have cemented the Fir Park side's win.
But the Bell's First Division side's striker Sean O'Connor netted a double in four second-half minutes to set up a thrilling climax.
The visitors had brought an impressive travelling support to Fir Park but they were stunned inside the second minute when defender Andy Aitken clumsily bundled
Motherwell striker David Clarkson to the ground inside the box.
Referee Mike McCurry had little option but to point to the spot and Adams stepped up to slam the ball past Queens goalkeeper John Dodds.
In the seventh minute, the home side should have made it 2-0 when Burns hit Dodds from close range and, from the rebound, the Queens keeper brilliantly pushed Clarkson's shot on to the bar before the danger was cleared.
Queens' first real effort on goal came in the 17th minute when midfielder Paul Burns cut in from the left but his curling right-footed shot from just outside the box went wide.
But, a minute later, Motherwell doubled their lead through Burns, with his first goal for the Fir Park club since he returned from Partick Thistle in the summer.
An in-swinging Adams corner from the left found the striker unmarked inside the six-yard box and he easily guided his header into the net.
The visitors tried hard to get back into the game but, despite their tenacity, Burns grabbed his second in the 45th minute after Dodds parried an Adams' shot to the feet of the striker, who netted from close range.
The conditions rapidly deteriorated at the interval and, after the break, it looked like the visitors' only chance of rescuing the tie was if referee McCurry abandoned the game.
In the 48th minute, Well midfielder Jason Dair had a volley on target from 12 yards but Dodds saved easily.
But the First Division side gave themselves a lifeline in the 64th minute when Stephen Payne's free-kick from the left found the head of top scorer Sean O'Connor, who headed powerfully past Gordon Marshall from close range.
But there was further drama four minutes later as O'Connor really put the cat among the pigeons when his shot from 15 yards, after the Well defence hesitated,
flew low past Marshall and into the corner of the net.
The visitors were now in search of an incredible equaliser and, in the 80th minute, Marshall flew to his left to push a powerful Paul Burns' drive past the
post for a corner.
Ultimately, the visitors just could not find the equaliser their spirited play deserved and careless Motherwell were left to prospect of another Division One
side in the last eight.
Teams
Motherwell Marshall, Corrigan, Hammell, Lasley (Bollan 77),
Adams, Craigan, Dair, O'Donnell, Burns (Scott McDonald 88),
Clarkson, Quinn.
Subs Not Used: Corr, Fagan, Kinniburgh.
Goals: Adams 3 pen, Burns 18, 45.
Queen of South Dodds, Paton, McAlpine (McMullan 59), Bagan,
Reid, Aitken, O'Connor, Bowey, Wood (Jaconelli 61),
Payne (McColligan 69), Burns.
Subs Not Used: Robertson, Burke.
Booked: Wood, Jaconelli.
Goals: O'Connor 65, 69.
Att: 8,101
Ref: M McCurry (Scotland).