Match ends, Motherwell 1, Inverness CT 2.
A stunning stoppage-time goal from Jordan Roberts put holders Inverness into the Scottish Cup quarter-finals.
Miles Storey gave Inverness the lead on 39 minutes, lashing home from close range for his ninth goal of the season.
Scott McDonald levelled for Motherwell midway through the second half when he tapped home Stephen McManus' header.
The tie looked to be heading for a replay until Roberts' magnificent long-range strike ensured Inverness' Cup defence carries on into the last eight.
The first shot on target came from Greg Tansey - the subject of much controversy during the week following Aberdeen's failed bid for him - but Connor Ripley saved his free-kick.
Ripley might also have got a slight touch on Carl Tremarco's header, which looped on to the crossbar.
McDonald then headed against the bar at the other end following an excellent cross from Marvin Johnson.
The opener came when Tremarco got to the byline to drive the ball back into the six-yard box, where Storey was waiting to bundle the ball home, though the final touch may have been off McManus.

Cadden and McDonald had ambitious efforts saved and the former set up Stephen Pearson with an inch-perfect cross, but the midfielder missed his kick.
Inverness began to threaten on the break with Danny Williams and Storey failing to make the most of decent chances before the pair linked up with Williams forcing a close-range stop from Ripley.
The home fans began to shout for Moult and Lionel Ainsworth before a section told McGhee: "You don't know what you're doing."
As Moult prepared to come on, Motherwell reasserted themselves as an attacking force after Cadden's forward run led to a free-kick.
Johnson had a shot deflected wide after the delivery and Motherwell levelled from the resulting corner. McManus ran from deep to meet Steven Hammell's cross on the edge of the box and McDonald diverted his header home from close range.
Moult initially stayed in the dugout as Inverness got back on top before being brought on for Keith Lasley with seven minutes left.
But it was another substitute who stole the show as Motherwell lost a costly late goal for a third consecutive game.
Roberts fired an unstoppable drive from all of 30 yards, which flew past Ripley to break Motherwell hearts and ensure Inverness' cup defence will carry on until at least the quarter-final stage.
Line-ups
Motherwell
Formation 4-4-1-1
- 1Ripley
- 18Law
- 16Kennedy
- 6McManus
- 3Hammell
- 26Cadden
- 14LasleySubstituted forMoultat 83'minutes
- 8PearsonBooked at 77mins
- 17Gomis
- 11Johnson
- 77McDonaldSubstituted forAinsworthat 88'minutes
Substitutes
- 5Laing
- 7Ainsworth
- 13Samson
- 15Chalmers
- 20Moult
- 21Leitch
- 23Thomas
Inverness CT
Formation 4-2-3-1
- 25Fon Williams
- 2Raven
- 5Warren
- 14DevineBooked at 66mins
- 3Tremarco
- 16Tansey
- 27VigursSubstituted forHughesat 89'minutes
- 28Mbuyi-MutomboBooked at 54minsSubstituted forRobertsat 57'minutes
- 8Draper
- 19Williams
- 39StoreySubstituted forPolworthat 70'minutes
Substitutes
- 1Esson
- 7Williams
- 11Roberts
- 15Wedderburn
- 20Polworth
- 21Hughes
- 34Brown
- Referee:
- Steven McLean
- Attendance:
- 3,907
Match Stats
- Possession
- Home52%
- Away48%
- Shots
- Home7
- Away9
- Shots on Target
- Home4
- Away5
- Corners
- Home3
- Away3
- Fouls
- Home15
- Away14
Live Text
Post update
Full Time
Second Half ends, Motherwell 1, Inverness CT 2.
Post update
Ross Draper (Inverness CT) wins a free kick in the attacking half.
Post update
Foul by Louis Moult (Motherwell).
Goal!
Goal! Motherwell 1, Inverness CT 2. Jordan Roberts (Inverness CT) left footed shot from outside the box to the top left corner.
Post update
Gary Warren (Inverness CT) wins a free kick on the left wing.
Post update
Foul by Louis Moult (Motherwell).
Substitution
Substitution, Inverness CT. Liam Hughes replaces Iain Vigurs.
Substitution
Substitution, Motherwell. Lionel Ainsworth replaces Scott McDonald.
Post update
Attempt saved. Danny Williams (Inverness CT) left footed shot from outside the box is saved in the centre of the goal.
Post update
Foul by Jordan Roberts (Inverness CT).
Post update
Morgaro Gomis (Motherwell) wins a free kick in the attacking half.
Post update
Ross Draper (Inverness CT) wins a free kick in the attacking half.
Post update
Foul by Scott McDonald (Motherwell).
Substitution
Substitution, Motherwell. Louis Moult replaces Keith Lasley.
Post update
Foul by Greg Tansey (Inverness CT).
Post update
Stephen Pearson (Motherwell) wins a free kick in the attacking half.
Post update
Attempt blocked. Liam Polworth (Inverness CT) right footed shot from outside the box is blocked.
Post update
Danny Williams (Inverness CT) wins a free kick in the defensive half.
Post update
Foul by Steven Hammell (Motherwell).