Gary Mackay-Steven fired Dundee United into the Scottish Cup semi-finals as Jackie McNamara tasted victory in his first derby as manager.
The winger drilled a shot under Rab Douglas in the 35th minute of an absorbing first half at Dens Park after Dundee midfielder Jim McAlister had cancelled out Brian McLean's headed opener.
Dundee had brought in John Brown as interim manager the previous weekend in a bid to save their season but United maintained the upper hand in the city clashes. However, this was closer than the previous three encounters, including a pre-season friendly, which all ended 3-0 to the Tannadice men.
Both sides were forced into changes. United striker Johnny Russell failed to overcome a leg knock which forced him off against Inverness on Wednesday, Stuart Armstrong coming in.
Gary Harkins was cup-tied for Dundee, with Steven Milne coming in, while Brown reshuffled his defence as Davide Grassi and Brian Easton replaced Declan Gallagher and Kyle Benedictus.
United took the lead in the 11th minute in controversial circumstances. Dundee claimed Mackay-Steven had run the ball out of play on the right wing but linesman Andrew McWilliam did not agree and the winger cut inside Brian Easton and Ryan Conroy before being brought down by the latter.
Barry Douglas swung in the free-kick and McLean rose above everyone else to beat Dundee goalkeeper Douglas to the ball and head into an empty net from inside the six-yard box.
United were in control and Mackay-Steven might have got a penalty when he fell under Easton's clumsy challenge after Jon Daly had won an aerial challenge against a hesitant Grassi, but referee Iain Brines waved play on.
Conroy saw a free-kick comfortably saved by Radoslaw Cierzniak but the hosts looked flat until they equalised out of the blue with 19 minutes gone.
Dundee worked the ball into the box to John Baird, who laid it off for McAlister to slot into the bottom corner from 16 yards and spark bedlam as the home fans celebrated a derby goal for the first time in eight years.
There was a pile-up of fans at the bottom of the south enclosure with paramedics being called in shortly afterwards but nobody appeared badly hurt.
The SPL bottom club were transformed by the goal. McAlister got on the ball and drove them forward and Nicky Riley and Conroy were both putting the ball in from wide as United were pressed back.
Conroy's long free-kick handed both Grassi and Baird a chance, but the Italian made a mess of his header and Baird's drive was blocked by the feet of Cierzniak.
But the visitors regained the lead against the run of play in the 35th minute. Armstrong broke forward from midfield, ran at the heart of the United defence and slipped the ball through for Mackay-Steven who ran inside and drilled a left-footed shot from 18 yards that flew underneath Douglas and into the middle of the goal.
Dundee responded and Cierzniak made a theatrical diving save from Riley's long-range volley and then caught Grassi's header from the resulting corner.
But United also came close before the break when Douglas pushed wide Gardyne's deflected drive after the midfielder played a one-two with Armstrong.
Gardyne again tested Douglas 10 minutes after the restart with a turn and shot that the former Scotland goalkeeper pushed wide, but it was Dundee who were doing most of the attacking.
The home side forced a number of corners and got the ball in the box on other occasions but nothing would fall for them. Cierzniak punched away a Grassi header and McAlister did get a couple of shots away but both were awkward attempts with the ball in the air.
Brown brought on forward Mark Stewart for midfielder Riley in the 72nd minute as they gambled further and Colin Nish replaced Milne, but Dundee ran out of steam.
Grassi came closer with another header - but it was in his own box as he glanced Barry Douglas's free-kick back the way forcing his goalkeeper to produce an impressive diving save.
And United then held on comfortably, spending the final 10 minutes playing out time in the Dundee half.