A magnificent Paul McGowan strike sealed a vital victory for Dundee at Ayr United as the Dark Blues strengthened their play-off chances.
After a goal-less first-half the Dark Blues roared to victory in the second as Max Anderson broke the deadlock on 68 minutes.
That was followed by substitute Jonathan Afolabi on 74 minutes before McGowan curled in a beauty to cap a fine night on the road.
James McPake’s side had suffered poor defeats in their last two meetings with the Honest Men but came away with a vital win this time around – opening up a five-point gap on fifth place.
Charlie Adam dropped to the bench, along with Shaun Byrne and Cammy Kerr, after Dundee’s weekend cup defeat to St Johnstone.
That saw Jason Cummings, McGowan and Christie Elliott return to the starting line-up alongside centre-back Lee Ashcroft, who shrugged off a knock picked up against the Perth Saints.
The hosts themselves were smarting from a cup defeat, shocked 1-0 at home to League One Clyde, and made four changes.
Among them was former Dundee man Josh Todd, making his league debut after joining on loan from Falkirk, while Mark McKenzie led the line. The frontman netted twice for the Honest Men at Dens Park in a 3-1 win last month – the only two goals of his professional career so far.
Liam Fontaine and goalkeeper Adam Legzdins made their Dundee debuts in a meek November defeat at Somerset Park that brought the wrath of McGowan and Adam in the media.
And Fontaine had to be on his toes from the very start of the match as Joe Chalmers swung a testing cross in within a minute, the former Hibs defender whacking clear from seven yards out.
Dundee had plenty of the ball in the opening exchanges but it was Ayr who fashioned the first shooting chance after 16 minutes.
Left-back Patrick Reading found himself in space inside the area but fired his shot straight at Legzdins.
Minutes later, Cummings hooked a speculative volley towards the Ayr goal but it was an easy grab for home goalie Viljami Sinisalo.
And the on-loan Aston Villa keeper immediately set Todd free on the counter who won a corner. From Chalmers’ delivery, Legzdins palmed the ball straight to Luke McCowan in space on the edge of the area but the wideman fired well over the bar.
Ayr were having the better of the contest by this point, enjoying success down their left flank, while Dundee had been unable to hurt the home defence.
That almost changed on 32 minutes, however, as the formula that has brought so much success lately nearly worked once more.
McGowan corners to Ashcroft’s head has brought the Dark Blues plenty of joy in recent weeks – this time the big defender’s header was flicked just past the post by Cummings.
Five minutes after the break, Jordan Marshall picked up a yellow card after catching former Dundee and Queen of the South team-mate Todd with a painful boot to the face.
The Ayr man’s league debut ended early as he went off with a suspected broken nose, replaced by Tom Walsh.
The first half hadn’t been pretty with windy conditions and a bobbly pitch making pretty passing football difficult and the start of the second hadn’t been much better.
It took almost 15 minutes to have an effort on goal after the break, Ashcroft heading a Marshall free-kick on but Cummings smashed his volley well over from a tight angle.
On 63 minutes, a chance opened up for Ayr as Walsh found himself in space in the area but instead of striking at goal tried to find Chalmers.
Last man Elliott, though, was there to save the day for Dundee, getting a toe on the ball to clear.
Jonathan Afolabi was stripped and ready to try to inject some life into the contest on 68 minutes.
However, it was the man he was to replace in Cummings who created the goal that did just that.
McGowan sent the striker down the right flank with Cummings cutting inside and shooting. The effort was deflected into the path of Anderson, who swivelled and found the top corner with a fine finish.
And it was 2-0 on 73 minutes with that man Afolabi on hand to smash in his fourth goal of the season.
Dundee kept a corner alive with Christie sending in a deep cross. McGowan did well to hold off his man and lay the ball into the path of McMullan.
His shot hit a defender and fell for Celtic loanee Afolabi, who buried the ball beyond the stranded Sinisalo.
The best was yet to come for the Dark Blues, however, as they made it 3-0 in the closing stages.
Dundee played the ball about well before McMullan rolled a pass into the path of McGowan 20 yards out.
And the experienced midfielder used the outside of his foot to curl the ball over goalie Sinisalo and into the top corner.
A fine victory on the road after a tough first half sees Dundee move level with Raith in second and five points ahead of Dunfermline in fifth, having now played the same amount of games.
Ayr: Sinisalo, Houston, Baird, Ndaba, Reading, Muirhead, Murdoch (Barjonas 79), Chalmers (Wright 76), McCowan, Todd (Walsh 54), McKenzie.
Subs not used: Urminsky, Roscoe, Moffat, Miller.
Dundee: Legzdins, Elliott, Fontaine, Ashcroft, Marshall, Anderson (Byrne 81), McGowan (Adam 90), McMullan (Cameron 90), McDaid, Mullen, Cummings (Afolabi 69).
Subs not used: Ferrie, Kerr, Fisher.
Referee: Steven McLean.