Paul McMullan's own net goal was the difference in a third consecutive loss.
Paul McMullan's own goal gave Hibs a much-needed win and a chance to win the League Cup against Celtic.
The winger sent a diving headed into his own net to give the hosts a second win in 11 league games.
Kevin Nisbet and Chris Cadden both went off injured.
Ryan Sweeney was dismissed late in the game.
The 10th-place Dens Park side is two points above the bottom two, having played two more matches than both Ross County and St. Johnstone.
Hibs ended their four-game winless run with a victory at home, and are now within a point of Aberdeen in sixth.
Reaction as it happened.
The football guy backed the Hibs job.
The win they needed to help rebuild confidence was not completely convincing, but it was still a victory.
Gray restored captain Paul Hanlon and full-back Paul McGinn to the defence after the pair's suspensions, and his side showed plenty of attacking intent while lacking conviction in the final third.
You will struggle to see a better own goal than the cruel one on McMullan. The length of the pitch was torn down by three players after Paul McGowan's poor touch on the edge of the Hibs box.
McMullan flung himself at the ball, but it went into the top corner, and he could only watch in horror.
Liam Fontaine got back to block the goal-bound shot after Nisbet rounded the goalkeeper.
Jamie Murphy should have doubled the lead from the cross but he took a touch too much and Legzdins saved.
No team in the top flight has conceded more goals this season, but they struggled to test a vulnerable Hibs side.
Danny Mullen had a chance to equalise after Jake Doyle-Hayes sliced the ball into his path, but he missed the chance.
Despite an improved second-half performance there was no late rally from the visitors, and they had Sweeney dismissed in the dying embers when dissent earned the defender a second yellow.
Joe Newell was the man of the match.
The platform for the victory was provided by theMidfielder's composure and industry.
What did we learn?
Gray will likely stand aside before the final, but can bow out with his head held high.
The former club captain was able to switch from a three to a back four in the second half to help solidify his side. Hibs got three points and a first clean sheet in 11 games as they stopped the rot for their trip to Hampden.
The Hibs supporters will be anxious to see Cadden and Nisbet recover in time for Sunday's game.
Without the leadership of injured captain Charlie Adam, Dundee has quickly moved back into real trouble.
The visitors' luck was summed up by the bizarre own goal after a run of three wins in four. The Dens men have become a talisman, but his glaring miss was costly at the other end.
What did they say?
David Gray is delighted. We were outstanding in the first half. They gave me everything after the disappointment of the weekend.
I thought the own goal was a good finish. Boyle was on fire and he asked people to defend.
The first half was really poor. We were the better side in the second half.
Danny Mullen had a great chance, but he didn't take it. Who knows what will happen if that goes in?
What's next?
The League Cup final between Hibs and Celtic will be played on Sunday, and the teams will play each other the following day.
Hibernian
The city of Dundee.
Line-ups.
Match statistics.
Live text.
Formation 3-4-1-2.
27Cadden22Doyle-Hayes
1Macey
6McGinn
5eous.
4Hanlon.
Substituted for Doidgeat 21' minutes.
Substituted for Gogicat for 80 minutes.
11Newell
Stevenson is a person.
Campbell
10 Boyle.
Substituted forMurphy at the end of the game.
Substitutes.
8Wright.
9Doidge.
13Gogic
18Murphy
21Dabrowski
Allan
25Scott.
Formation 4-2-3-1.
2Kerr4Fontaine5Sweeney3Marshall
McMullan10McGowan17
1Legzdins
2Kerr
4Fontaine
5SweeneyBooked was 90 minutes long.
3Marshall.
Substituted forGriffithsat for 81 minutes.
6McGhee.
Substituted forummings at 78' minutes.
10McGowan.
17 McCawan
9Mullen
Substitutes.
7Jakubiak
16Elliott.
20Panter.
Lawlor.
29Griffiths
35ummings
The match ended with a 0
The second half ended with a zero.
Ryan Sweeney got a second yellow card.
Foul by Martin.
The attacking half has a free kick.
Hibernating, Offside. Jamie Murphy tries a through ball.
Josh Campbell won a free kick.
Foul by Cammy Kerr.
The attacking half has a free kick by Martin Boyle.
Foul by Jordan Marshall.
Josh Campbell won a free kick.
Foul by Jordan McGhee.
Hibernating, Offside. Lewis Stevenson tried a through ball, but Josh Campbell caught it.
Christian Doidge won a free kick in the defensive half.
Liam Fontaine had a foul.
The substitution was for Hibs. Gogic replaces Jake.
There was a substitution in Dundee. Max Anderson was replaced by Leigh Griffiths because of an injury.
Christian Doidge won a free kick in the defensive half.
Liam Fontaine had a foul.
There was a substitution in Dundee. Paul McMullan was replaced by Jason Cummings.