Goalkeeper Cammy Bell was Kilmarnock's hero as he saved a Matt Lockwood penalty to deny Dundee a top-flight scalp in the Scottish Cup fourth round.
Steven Milne had the ball in the net for the First Division side early on but was correctly ruled offside.
Manuel Pascali headed Killie ahead from a 32nd-minute corner.
But Milne poked in the equaliser a minute after the break before Lockwood's weak penalty and fine saves from Bell and counterpart Rab Douglas.
Dundee manager Barry Smith, whose side had only lost once in their last eight game, had adopted a more defensive formation than normal.
However, despite having only one out and out striker, his players quickly put Kilmarnock under pressure playing down the Dens Park slope.
Gary Irvine failed to get enough purchase on an early toe-poke straight at Bell after the full-back burst into the Kilmarnock box.
Veteran former Scotland midfielder Gavin Rae was thwarted by a Pascali block a few yards from goal after his defensive partner Mohamed Sissoko mis-timed his attempt to clear.
Kilmarnock at last broke out of their own half and Dean Sheils was unable to direct the ball on target with a volley from an awkward height 12 yards out.
Milne found the net after 15 minutes only to have his celebrations cut short when referee Stevie O'Reilly consulted assistant Charlie Smith.
The striker initially looked onside as he gathered Ryan Conroy's through ball before rounding Bell, but television replays showed that it had reached Milne via a flick from Ross Chisholm.
Although there were no Kilmarnock protests moments later, Heffernan looked to have more of a case for being onside when the flag went up when the striker was through on goal.
Kilmarnock had worked their way into the game, but it was still against the run of play when Pascali evaded his marker to beat a flapping Douglas to Shiels' corner floated to the front post.
Heffernan set up Shiels for a shot on the turn that slipped just wide of the far post from 14 yards, while Rae ought to have done better than drive a couple of feet over after finding himself in the clear just outside the penalty box.
There were to be no doubts about the Conroy-Milne combination a minute into the second half when Rae set the winger off towards the bye-line and his low cross was turned in by the striker's outstretched leg.
Douglas rolled back the years to superbly turn over the crossbar a powerful drive from Garry Hay before Dundee squandered a golden opportunity to take the lead when Sissoko pushed Conroy in the back as they jostled for a Jamie McCluskey cross.
However, Bell got down to hold Lockwood's poorly taken penalty kick.
Pascali sent a header just wide and had another effort saved by Douglas after a deflection off Rae.
The Dundee goalkeeper was upstaged by his opposite number when Bell produced a superb double save, blocking at the feet of Milne then stretching one-handed to turn wide a Conroy header when the ball was played back into the box.
Sorry, we were unable to load match stats, please try again.