Inverness Caley Thistle came from behind to book a lucrative Scottish Cup fifth-round tie against Celtic.
But it was another error from goalkeeper Chris Smith that brought Inverness back into the game.
Andrew Barrowman headed the opener five minutes before half time.
But Smith's poor clearance gifted Jonny Tuffey a 54th-minute tap-in, substitute Shinnie fired Inverness into the lead three minutes into extra time and Greg Tansey drilled in their third.
Dunfermline had home advantage but went into the game looking for their first win this season at East End Park, having not beaten Inverness in their last eight meetings and with Smith's howler in their previous meeting fresh in their minds.
There had to be a winner this time after the three draws in three games between the sides this term, but it was perhaps little surprise that it took extra time to separate them.
Inverness were the ones to go into the game full of confidence, Saturday's 1-0 win away to Motherwell having stretched their unbeaten run to four games following a recent improvement in form that has lifted them off the bottom of the Scottish Premier League.
They have been replaced there by a Dunfermline side who lost to relegation rivals Hibernian on Saturday and whose only win in 18 games came on 5 November.
But it was the Pars who started on the front foot, with Barrowman's swift shot on the turn looping a few yards wide from 18 yards within 20 seconds.
The striker should have opened the scoring a couple of minutes later when he took David Graham's pass over the visiting defence in his stride, but his weakly struck low shot from just inside the penalty box was palmed clear by goalkeeper Jonny Tuffey.
Tuffey was given his chance with Ryan Esson suffering a strain, while Ross Tokely replaced the suspended Kenny Gillet and Richie Foran was fit to come in for Nick Ross, but most eyes were on the Northern Irishman's opposite number.
Smith was back in goal for the first time since his awful mistake handed Jonny Hayes the stoppage-time equaliser that secured Caley Thistle the replay.
With on-loan Iain Turner ineligible and Paul Gallacher injured, the obviously nervous Smith's every touch was greeted with trepidation from the home support and expectation from the visitors.
However, it took Inverness 26 minutes to test Smith and a Dunfermline defence in which Kevin Rutkiewicz was making his first appearance since August in place of John Potter.
Even then, Tansey's shot from 10 yards was blocked before it reached the goalkeeper and it was the returning central defender who helped engineer the Pars' breakthrough.
Rutkiewicz sent Joe Cardle down the left and, when the winger turned back inside his marker, his cross found Barrowman at the back post to head home from five yards.
Inverness manager Terry Butcher went for broke, bringing on Shinnie for midfielder Lee Cox at half time and the forward had an immediate impact, sending wide a drive and setting up Billy Mckay from a shot that stung Smith's fingers.
The tide was turning, but it was another Pars howler that handed Caley Thistle the equaliser when Smith tried to clear Alex Keddie's loose backheader from an innocuous punt upfield, the ball rebounded off Rutkiewicz towards his own goal and Hayes tapped into the unguarded net.
Inverness were looking the more determined, exemplified by Hayes and Foran both being booked when the team-mates clashed angrily after 74 minutes.
Smith redeemed himself slightly by turning a powerful 20-yard drive from Shinnie over the crossbar.
Dunfermline survived the pressure and Ryan Thomson, who had started ahead of the experienced Gary Mason, powered into the penalty box only for Tuffey to save the midfielder's weak effort at the second attempt.
The home side paid for that and for failing to close down Shinnie as, three minutes into extra-time, the substitute fired a drive off the inside of the far post from 18 yards.
Tansey made sure of Caley Thistle's place in the next round when he gathered a pass from fellow sub Ross and fired into the corner from just outside the box for a deserved win but one that had another Dunfermline error as its catalyst.
- 20 Smith
- 05 Rutkiewicz (Potter - 75' )
- 06 Keddie
- 13 Boyle
- 15 Dowie Booked
- 07 Cardle
- 08 Hardie Booked
- 23 Thomson
- 09 Barrowman (Buchanan - 66' )
- 10 Kirk
- 11 Graham Booked (Willis - 62' )
- 30 Goodfellow
- 16 Potter
- 04 Mason
- 22 Willis
- 19 Buchanan
- 12 Tuffey
- 03 Tokely
- 16 Golobart (Proctor - 90' )
- 19 Shinnie
- 02 Piermayr Booked
- 06 Cox (Shinnie - 46' )
- 07 Hayes Booked
- 08 Tansey
- 09 Foran Booked
- 15 Tade
- 21 McKay (Ross - 87' )
- 01 Esson
- 14 Proctor
- 26 Meekings
- 10 Shinnie
- 11 Ross
Live Text Commentary
Extra time ends and the match is over.119:18
Ryan Thomson concedes a free kick for a foul on Johnny Hayes. Direct free kick taken by Richie Foran.118:01
Effort on goal by Martin Hardie from just inside the penalty area goes over the target.115:16
Foul by Gregory Tade on Alex Keddie, free kick awarded. Free kick taken by Chris Smith.110:47
Paul Willis takes a shot. Save by Jonny Tuffey. Inswinging corner taken right-footed by Joe Cardle, Jonny Tuffey makes a comfortable save.109:36
Assist by Nick Ross.109:36 Goal scored
Goal! - Greg Tansey - Dunf'mline 1 - 3 Inverness A goal is scored by Greg Tansey from the edge of the penalty box to the bottom left corner of the goal. Dunfermline 1-3 Inverness CT.108:37
Unfair challenge on Gregory Tade by Alex Keddie results in a free kick. Direct free kick taken by Thomas Piermayr.107:44
Free kick taken by Chris Smith.107:44 Booking
Booking Booking for Thomas Piermayr for unsporting behaviour.107:22
Greg Tansey gives away a free kick for an unfair challenge on Patrick Boyle.105:01
The referee blows his whistle to start the second half of extra time.104:38
Martin Hardie gives away a free kick for an unfair challenge on Johnny Hayes. Richie Foran takes the direct free kick.102:05
Gregory Tade is caught offside. John Potter restarts play with the free kick.100:31
Inswinging corner taken by Joe Cardle.97:24
Free kick awarded for a foul by Johnny Hayes on Paul Willis. Chris Smith restarts play with the free kick.95:26
Shot by Richie Foran from outside the box goes over the target.92:20
The assist for the goal came from Gregory Tade.92:20 Goal scored
Goal! - Andrew Shinnie - Dunf'mline 1 - 2 Inverness Andrew Shinnie finds the back of the net with a goal from the edge of the penalty box to the top left corner of the goal. Dunfermline 1-2 Inverness CT.90:00 +4:21
Normal time is of over and the game goes into extra time.
Ross Tokely takes the free kick.89:58 Substitution
Substitution David Proctor on for Roman Golobart.89:58
Roman Golobart fouled by Paul Willis, the ref awards a free kick.86:31
Corner taken by Joe Cardle, Ross Tokely makes a clearance.85:52
Chris Smith restarts play with the free kick.85:52 Substitution
Substitution Billy McKay leaves the field to be replaced by Nick Ross.85:52
Free kick awarded for an unfair challenge on Paul Willis by Graeme Shinnie.84:04
Joe Cardle takes the inswinging corner, clearance by Gregory Tade.83:18
Effort from deep inside the area by Andy Kirk misses to the left of the target.82:28
Patrick Boyle fouled by Gregory Tade, the ref awards a free kick. Alex Keddie takes the free kick.79:36
The free kick is swung in right-footed by Greg Tansey.79:36 Booking
Booking Andy Dowie receives a yellow card for unsporting behaviour.79:29
Foul by Andy Dowie on Johnny Hayes, free kick awarded.77:57
Corner from the left by-line taken by Joe Cardle, Foul by Andy Kirk on Roman Golobart, free kick awarded. Jonny Tuffey takes the free kick. Ryan Thomson takes a shot. Save by Jonny Tuffey.76:36
Andrew Shinnie takes a shot. Save made by Chris Smith. Corner taken right-footed by Greg Tansey, comfortable save by Chris Smith.73:59 Substitution
Substitution Kevin Rutkiewicz leaves the field to be replaced by John Potter.73:59 Booking
Booking Booking for Richie Foran for unsporting behaviour.73:58 Booking
Booking Johnny Hayes is cautioned.70:58
Graeme Shinnie challenges Andy Dowie unfairly and gives away a free kick. Chris Smith restarts play with the free kick.69:17
Ryan Thomson challenges Andrew Shinnie unfairly and gives away a free kick. Free kick crossed left-footed by Johnny Hayes.65:33 Substitution
Substitution Liam Buchanan is brought on as a substitute for Andrew Barrowman.64:38
Corner taken by Johnny Hayes from the right by-line played to the near post, clearance made by Martin Hardie.62:37
Martin Hardie fouled by Andrew Shinnie, the ref awards a free kick. The free kick is swung in right-footed by Joe Cardle.61:51
Graeme Shinnie takes the free kick.61:51 Substitution
Substitution (Dunfermline) makes a substitution, with Paul Willis coming on for David Graham.61:51
The referee blows for offside.59:46
Roman Golobart fouled by Andrew Barrowman, the ref awards a free kick. Jonny Tuffey takes the free kick.58:26
Inswinging corner taken by Greg Tansey, Kevin Rutkiewicz makes a clearance.57:06
Joe Cardle challenges Richie Foran unfairly and gives away a free kick. Direct free kick taken by Ross Tokely.56:19
Direct free kick taken by Graeme Shinnie.56:19 Booking
Booking David Graham goes into the referee's book.56:09
Greg Tansey fouled by David Graham, the ref awards a free kick.53:17 Goal scored
Goal! - Johnny Hayes - Dunf'mline 1 - 1 Inverness Johnny Hayes grabs a goal from close in low into the middle of the goal. Dunfermline 1-1 Inverness CT.51:06
Free kick awarded for a foul by David Graham on Graeme Shinnie. Graeme Shinnie takes the direct free kick.48:01
Gregory Tade is flagged offside by the assistant referee. Chris Smith restarts play with the free kick.46:58
Effort from a long way out by David Graham goes wide right of the target.45:58
Shot from just outside the box by Andrew Shinnie misses to the right of the goal.45:01
The second half kicks off.45:01 Substitution
Substitution Lee Cox goes off and Andrew Shinnie comes on.45:00 +0:57 Half time
Half Time The half-time whistle blows.44:51
Free kick awarded for a foul by Andy Kirk on Richie Foran. Greg Tansey restarts play with the free kick. Thomas Piermayr takes a shot. Save made by Chris Smith.43:32
Andy Kirk gives away a free kick for an unfair challenge on Ross Tokely. Direct free kick taken by Roman Golobart.42:52
Richie Foran concedes a free kick for a foul on Ryan Thomson. Chris Smith restarts play with the free kick.41:25
Inswinging corner taken left-footed by Johnny Hayes played to the near post, clearance made by Andy Dowie.39:01
The assist for the goal came from Joe Cardle.39:01 Goal scored
Goal! - Andrew Barrowman - Dunf'mline 1 - 0 Inverness Andrew Barrowman scores a headed goal from close range. Dunfermline 1-0 Inverness CT.38:34
Unfair challenge on Joe Cardle by Gregory Tade results in a free kick. Ryan Thomson takes the direct free kick.37:06
Strike on goal comes in from Greg Tansey from the free kick.37:06 Booking
Booking Martin Hardie booked for unsporting behaviour.36:58
Martin Hardie concedes a free kick for a foul on Lee Cox.36:30
Unfair challenge on Lee Cox by Martin Hardie results in a free kick. Thomas Piermayr takes the free kick.35:27
Billy McKay is flagged offside by the assistant referee. Chris Smith takes the indirect free kick.32:30
Ross Tokely concedes a free kick for a foul on Joe Cardle. Martin Hardie produces a strike on goal direct from the free kick, Jonny Tuffey makes a comfortable save.30:50
Andrew Barrowman fouled by Thomas Piermayr, the ref awards a free kick. Joe Cardle crosses the ball in from the free kick, clearance by Johnny Hayes.28:36
Billy McKay concedes a free kick for a foul on Kevin Rutkiewicz. Chris Smith takes the free kick.27:02
Greg Tansey concedes a free kick for a foul on Ryan Thomson. Direct free kick taken by Chris Smith.26:04
Greg Tansey takes a shot. Comfortable save by Chris Smith. David Graham gives away a free kick for an unfair challenge on Graeme Shinnie. Jonny Tuffey takes the direct free kick.24:26
Billy McKay concedes a free kick for a foul on Kevin Rutkiewicz. Direct free kick taken by Chris Smith. Andy Kirk takes a shot. Save made by Jonny Tuffey.23:28
Andrew Barrowman challenges Ross Tokely unfairly and gives away a free kick. Free kick taken by Jonny Tuffey.20:07
The offside flag is raised against Andy Kirk. Jonny Tuffey restarts play with the free kick.19:10
Free kick awarded for an unfair challenge on Greg Tansey by David Graham. Greg Tansey crosses the ball in from the free kick, comfortable save by Chris Smith.17:09
Andy Kirk fouled by Roman Golobart, the ref awards a free kick. Kevin Rutkiewicz restarts play with the free kick.13:26
Unfair challenge on Gregory Tade by Andy Dowie results in a free kick. Graeme Shinnie takes the direct free kick.10:15
Free kick awarded for an unfair challenge on Lee Cox by Martin Hardie. Thomas Piermayr takes the free kick.9:13
Johnny Hayes takes a shot. Chris Smith makes a comfortable save.8:40
Martin Hardie gives away a free kick for an unfair challenge on Lee Cox. Direct free kick taken by Thomas Piermayr.7:18
Richie Foran challenges Andrew Barrowman unfairly and gives away a free kick. Martin Hardie has a direct shot on goal from the free kick, comfortable save by Jonny Tuffey.5:19
David Graham challenges Johnny Hayes unfairly and gives away a free kick. Free kick taken by Jonny Tuffey.4:32
Patrick Boyle takes a shot. Blocked by Thomas Piermayr. Joe Cardle takes the inswinging corner, save by Jonny Tuffey.3:33
Unfair challenge on Richie Foran by Ryan Thomson results in a free kick. Ross Tokely takes the free kick.1:56
Andrew Barrowman takes a shot. Save made by Jonny Tuffey.0:06
Andrew Barrowman has an effort at goal from outside the area which misses left.0:00
The ref blows the whistle to start the match.
Live data and text provided by our data suppliers