A great solo goal from Barry Nicholson sealed victory for Dunfermline over Inverness and booked a Scottish Cup final meeting with Celtic on 22 May.
Dunfermline won a place in the Scottish Cup final
First Division Inverness took a sixth-minute lead through Paul Ritchie.
But Darren Young equalised from close range before the break and Craig Brewster put Dunfermline ahead with a powerful angled shot after 63 minutes.
With 12 minutes to go Nicholson rounded several challenges to score, and David Bingham hit a late consolation penalty.
A crowd of less than 6,000 made the journey to Pittodrie for the replay.
But they were rewarded with an entertaining match, and the Pars fans can now look forward to their first final since 1968 and a place in next season's Uefa Cup.
Dunfermline had the first opportunity of the game when Brewster found himself with the ball just inside the penalty area, but he could not keep his shot down.
The Highlanders had a decent chance when Liam Keogh's cross into the box sparked a scramble and Bingham bulleted a header just wide.
The First Division side then took the lead when Bingham sprinted into Dunfermline territory before sending a 40-yard pass to the feet of Ritchie, who coolly slotted past Derek Stillie from 15 yards.
Caley Thistle could have added to their lead when Keogh's corner picked out Steven Hislop, but he nodded narrowly wide of the upright from close range.
Dunfermline were back on level terms after 24 minutes when Brewster released Lee Bullen down the left wing and he squared for Darren Young to stab home from six yards out.
The Pars should have taken the lead on the half hour when Derek Young flighted a cross to Brewster just a few yards out.
Paul Ritchie put Inverness in front at Pittodrie
But Mark Brown produced a superb save to block the header before the striker hit the rebound off the post.
Dunfermline continued to push forward before half-time and came close when Brewster found Gary Dempsey at the far post.
Dempsey tried to scramble the ball over the line but Stuart McCaffrey managed to clear.
Brewster then saw Brown get his fingertips to a scorching shot from 20 yards.
Inverness were on top early in the second period and went close twice in the space of a few minutes.
Hislop cut inside Andrius Skerla and smacked the ball off Stillie's crossbar from 10 yards.
Dunfermline could not clear their lines properly, allowing Stuart Golabek to fire in a shot that bobbled off the turf and went inches wide.
But the Premier League side snatched the lead when the ever-impressive Brewster raced clear of the defence and, from the tightest of angles, powered a shot across Brown's body, off the far post and into the net.
In the 78th minute Nicholson picked up the ball on the right flank and cut inside, leaving a trail of defenders in his wake before beating Brown with a neat sidefoot finish.
Deep into injury time Scott Wilson was guilty of tripping substitute Darren Mackie and former Pars favourite Bingham smashed the ball home from the penalty spot.
Inverness CT: Brown, Tokely (Proctor 85), Mann, McCaffrey, Golabek, McBain, Duncan (Thomson 50), Bingham, Hislop, Keogh, Ritchie (Mackie 76). Subs Not Used: Munro, Fraser. Booked: Bingham, Hislop.
Dunfermline: Stillie, Bullen, Scott Wilson, Skerla, Dempsey (Byrne 67), Darren Young, Nicholson, Mason (Labonte 76), Derek Young, Brewster, Crawford. Subs Not Used: Tod, Mehmet, Scott Y Thomson.
Referee: H Dallas