El Bakhtaoui's 11th minute opener was cancelled out by Kane Hemmings but the Pars, indebted to goalkeeper Sean Murdoch throughout the second half, sealed a sensational win with late goals from Cardle and El Bakhtaoui to send the top flight Dees crashing out.

It was a magnificent night of cup drama and a victory that Allan Johnston's side earned through a power of work and no shortage of good play.

There was one change to the Pars side that lost to Peterhead on Saturday as Shaun Byrne made way in midfield for Josh Falkingham, while Dees boss Paul Hartley was without Rory Loy and Kevin Thomson.

The visitors got the match underway but it was Dunfermline who immediately created the first opportunity.

A good turn from Michael Moffat took him away from James McPake midway inside the Dundee half and he slipped the ball to Joe Cardle, but his vicious shot ended the wrong side of Scott Bain's near post.

It was a confident start from the Pars but Sean Murdoch had to be alert to save a header from Julen Extabeguren.

Pre-match thoughts that this could be an open cup tie were proving accurate and Cardle came even closer in the eighth minute when he controlled Moffat's knockdown on his chest before firing a volley that Scott Bain saved well.

The East End faithful were soon turning up the volume though as their side took an 11th minute lead.

Good play saw the ball swept out to Lewis Martin on the right, and his cross was met brilliantly by El Bakhtaoui as his first time finish from 12 yards into the bottom corner left Bain with no chance.

It was terrific stuff from Dunfermline and there were appeals for a penalty in the 22nd minute when Michael Paton went down after knocking the ball beyond Nick Ross, but referee Stephen Finnie judged that the Dundee man had played the ball out for a corner.

The Dark Blues gradually began to have more of the ball but a McPake shot from 30 yards that trundled harmlessly wide on the half hour mark caused no concern.

They continued to press however and former Cowdenbeath man Hemmings failed to hit the target with a weak effort before Thomas Konrad headed wide from a corner.

Dunfermline were struggling to keep possession as the half wore on and Gary Harkins was desperately uunlucky not to level three minutes before half-time.

Lovely skill from El Bakhtaoui saw him spin towards halfway but after an unfortunate slip, Dundee regained the ball and while Harkins' deft lob from the edge of the box beat Murdoch, it clipped the top of the bar.

But it only took three minutes of the second half for the Premiership outfit to pull themselves level.

Paul McGowan's cross from the left found Paul McGinn on the right hand edge of the box, and his header was cleverly dummied by Ross to find the unmarked Hemmings to drill home from 12 yards.

Dundee were well on top now and only a brilliant save from Murdoch to claw the ball away underneath his bar from Hemmings' header kept his side level.

A late challenge from McGinn on Moffat ended with the Dundee man booked but an incensed Allan Johnston was sent to the stand for his protests after Finnie refused to bring play back for a Pars free kick.

Dundee came close again in the 74th minute when superb play from Greg Stewart saw him play a neat one-two with Hemmings at the edge of the area before sending a curling shot narrowly wide of goal.

Murdoch then produced a smart block to deny Hemmings before moments later Dylan Carreiro latched on to a through ball but his lob ended wide of target.

It was all Dundee now and Murdoch again was called into action to produce a flying finger tip save from Kevin Holt's 25-yard drive.

But with four minutes left, East End erupted as Dunfermline regained the lead in dramatic fashion.

Paton was the creator, slipping a lovely weighted ball through for Cardle to slip the ball under Bain from 10 yards.

And deep into stoppage time El Bakhtaoui sealed Pars' third round when he seized on Michael Paton's pass to dance beyond McPake and fire home from close range.

Pars: Murdoch, Martin, Talbot, Fordyce, Richards-Everton, Geggan, Paton, Falkingham, Moffat, El Bakhtaoui, Cardle.

Subs: Hutton, Thomas, Byrne, Hopkirk, Wallace, Crossan, Potter.

Dundee: Bain, Holt, Konrad, McPake, Etxabeguren, Ross, McGowan, McGinn, Harkins, Stewart, Hemmings.

Subs: Irvine, Mitchell, Megatt, Gadzhalov, Black, Curran, Carreiro.

Referee: Stephen Finnie.