Media playback is not supported on this device
Ali Crawford's clinical finish had Accies ahead on the half-hour mark.
Dundee were two behind when Jesus Garcia Tena scored a penalty after Julen Extabeguren fouled Eamonn Brophy.
A classy Gary Harkins finish made the hosts nervous, but they remained resolute for a huge victory that lifts them 12 points clear of bottom place.
Accies' win also preserved the four-point gap between themselves and Kilmarnock, who currently occupy the relegation play-off spot.
Dundee will be dejected, dropping to seventh just before the split after occupying the top half of the table for a huge part of the season.
Hamilton showed slightly surprising confidence in the opening 15 minutes, really taking the game to their visitors despite such a poor home record this term.
Greg Docherty - who scored in their previous match at New Douglas Park - was set up nicely by the returning Carlton Morris before the young midfielder had a rasping shot tipped over by Dundee goalkeeper Scott Bain.
Accies' next effort came from the instep of forward Brophy, whose curled attempt landed the wrong side of the post.
When Hamilton defender Lucas Tagliapietra needed to leave the pitch to get a bloodied head cleaned up following a clash with team-mate Ziggy Gordon, the Dark Blues nearly took advantage.
A poor Michael McGovern kick was snapped up by Greg Stewart, who nudged the ball into Kane Hemmings' path, but the former Barnsley man watched his low shot saved by a grateful McGovern.
On the half-hour mark Accies went ahead and Crawford's fifth goal of the season owed much to the strength of forward Brophy.
The 20-year-old outmuscled his marker in the box to ensure he could set up Crawford to drive low into the bottom corner. Crawford - quieter this season than last - showed great technique with his finish.
Things got even better for Martin Canning's side 10 minutes later. The spot-kick owed much to the industry of Brophy with his dash into the box inviting an ill-timed challenge by Extabeguren, who despite already being booked received no further punishment.
Garcia Tena stepped up and calmly put the ball it into the right side of Bain's net for his fourth goal of the campaign.
Dougie Imrie's challenge on Cammy Kerr raised the temperature in what was already a feisty atmosphere, with the winger exchanging angry words with visiting manager Paul Hartley on the touchline.
But for a great save by Bain, Crawford's header would have put Accies three ahead, then Garcia Tena went close with a free-kick just after the break.
Dundee would score next, though, and substitute Harkins' goal was very clever. He raced on to a fine pass by Hemmings and flicked it past the onrushing McGovern from eight yards and right in front of the Dark Blues' support, which got them buoyant.
McGovern reacted well soon after to smother Thomas Konrad's header as the visitors applied more pressure, that ultimately did not pay off.
Hamilton Academical recorded their first home win in over six months and scuppered Dundee's Premiership top-six hopes in the process.