Aaron Doran’s stoppage-time header sent Inverness Caley Thistle into the Scottish Cup semi-final at the expense of Dundee United.
A contentious penalty converted by Nicky Clark looked to have earned United a replay despite the hosts toiling for long spells.
Joe Chalmers had given the visitors the lead with a stunning opener and also hit another shot off the crossbar.
But, with seconds left on the clock, Doran nodded in from close range.
The Highlanders had always looked the more likely to find a winner and had a late header from Nathan Austin chopped off for offside by the slimmest of margins.
Caley Thistle join Celtic in the last four and are back at Hampden for the first time since they won the competition four years ago.
United fail to handle the pressure
Having beaten the visitors in the Championship on Tuesday, United head coach Robbie Neilson said the pressure was on his side to make the semi-final.
If they were feeling pressure, they did not handle it well, with the home side beginning on the back foot and staying there for much of the game.
Early on Doran had a shot tipped wide, then Coll Donaldson and Jordan White went close with headers as the Highlanders looked to take the sting out of a frenzied atmosphere inside Tannadice.
And they soon dampened it completely when they made their early domination tell. Chalmers cut onto his left foot, sized up the goal and curled a delightful shot into the top corner.
Rather than spark United, they retreated further into their shell. A deflected cross fell to Chalmers who thumped a volley against the bar.
Chalmers was the only one showing any quality in the final third though, as both goalkeepers watched a glut of chances fly too high.
It was never likely to be a goal-fest. In the past eight meetings between the pair, the most goals scored had been two.
Jamie McCart had a volley blocked and Charlie Trafford thundered a shot wide as the visitors sought a second goal.
But then, out of nothing, substitute Paul McMullan hit a pass from Ian Harkes first time, and won a corner. Following the set-piece, McMullan went down in the box under White’s challenge, and Clark put the resultant penalty into the bottom corner.
The visitors were furious with the decision but were soon creating chances again.
United goalkeeper Benjamin Siegrist got down well to block White’s shot, before racing out to deny the same man when he had turned Mark Reynolds.
Austin headed a free-kick into the net but the celebrations were cut short, with TV replays showing his elbow was enough to rule him offside.
After 90 seconds of the three minutes added on, White nodded the ball across goal for Doran who had raced into the box and the little midfielder bravely planted his header past Siegrist.
Winners wanted it more – analysis
BBC Scotland’s Jane Lewis at Tannadice
On the first half showing, Caley Thistle wanted it more. They took the lead with a stunning strike from Joe Chalmers, and controlled things thereafter.
Yes, Dundee United got back into the match with a penalty, some thought was soft, but the Highlanders deserved to leave Tannadice with their name in the hat for the semi-finals.
They kept at Dundee United and the heads didn’t go down, even when they felt refereeing decisions had gone against them. John Robertson’s side showed great spirit and fight and, although the league is their priority, a cup run will do wonders for confidence.