Goals in either half of regulation time from defender Eddie Malone and winger Craig Forsyth looked to have earned the First Division favourites a deserved scalp before the Dons restored parity in a stirring comeback with a double from substitute Michael Paton.
The momentum looked to have swung the way of the visitors but Griffiths pounced in the closing seconds of the first half of extra-time to seal the Dens Park outfit's passage into the quarter-finals.
Having exited the Europa League in embarrassing fashion it was another knock-out night to forget for the Dons' one-time European Cup Winners' Cup hero Mark McGhee.
The Pittodrie boss saw his team outfought and outplayed by their hosts, apart from their late second-half rally.
The big-spending home side made four changes to the team which went down 2-0 to Queen of the South on Saturday as they looked to shake off poor league form and prove they deserve to be an SPL outfit.
But it was the second-half introduction of one of those dropped from the weekend, Griffiths, which proved crucial.
Visitors Aberdeen made two alterations, with Paton dropping down to the bench and Sone Aluko having finally departed with Nigeria to the Under-20 World Cup, and they were quickly forced into another change with only nine minutes on the clock when Davide Grassi succumbed to a face injury.
Referee Steve Conroy sparked controversy at the weekend with his card-happy display in the goalless draw between Kilmarnock and Rangers and he was again put on the spot in the 10th minute.
Dundee winger Forsyth went down in the box under the combined challenge of Jonathon Crawford and Ricky Foster but Conroy was not impressed and waved play on.
Lee Miller shot over for Aberdeen and substitute Peter Pawlett then had a shot held by Douglas before the goalkeeper limped off to be replaced by Bullock.
Aberdeen had not conceded a goal in four games but five minutes from the interval their resolute rearguard finally cracked.
Gary Harkins' curling free-kick from the right exposed terrible marking in the Dons' box and full-back Malone steamed in to head past Jamie Langfield.
Dundee came out after the break seeking to double their lead and they should have got it in the 51st minute as McMenamin passed up a glorious opportunity.
Dons defender Jerel Ifil missed his header 40 yards out but, after racing clear on goal, McMenamin clipped his shot wide of the target.
However, McMenamin made amends for that miss by playing a crucial part in Dundee eventually going two ahead in the 55th minute.
Harkins picked out the striker in the box and, despite taking a poor touch, the former Livingston marksman had the presence of mind to back heel into the path of Forsyth who fired high into the net from the apex of the six-yard box.
McGhee reacted immediately by throwing on strikers Chris Maguire and Paton for Crawford and Darren Mackie and the switch paid immediate dividends as the latter earned his side a 63rd-minute lifeline.
The reliable left foot of Charlie Mulgrew curled a corner in from the right towards a crowded near post and Paton appeared to bundle past Bullock's despairing dive.
The goal reinvigorated the visitors and Maguire could have snatched a dramatic equaliser in the 89th minute when he shot across goal.
But seconds later fellow substitute Paton succeeded in sending the tie into extra-time with his second of the tie.
Miller laid the ball off into the youngster's path and he sent a low shot past Bullock from just inside the box.
Bullock proved Paton's match in the first-half of extra-time, however, as he beat away a curling drive from the marksman.
And the stop proved crucial as Dundee went back in front in the 14th minute of extra-time. A through-ball found its way to Griffiths on the edge of the box and when he was confronted by the advancing Langfield he turned full circle and shot into the empty net.
Griffiths should have sealed the win but sent a free header over in the 108th minute and Miller volleyed narrowly over at the other end as time eventually ticked away from Aberdeen.