Dundee slumped to a heavy last day defeat on an afternoon in which the team needing the win most seized the moment.
Accies knew that a loss, coupled with an Inverness victory against Motherwell, would send them into the Championship.
Two goals within a minute midway through the first half – from Rakish Bingham and Ioannis Skondras – made that a highly unlikely prospect.
Dougie Imrie added a second half penalty and Ali Crawford completed the scoring.
Now they face a play-off final (with a bit of momentum) against Dundee United.
For Dundee, who finish 2016/17 in 10th position, this was typical end of season stuff. The agenda will now switch to whether or not Neil McCann will continue as manager into the next campaign.
There was plenty of effort but precious little quality in the opening stages and it wasn’t until the 20th minute that the game produced a chance at either end.
Skondras lost possession and Faissal El Bakhtaoui quickly moved the ball on to Paul McGowan, whose shot on the angle was comfortably saved by Remi Matthews.
The match had come to life at last and on 24 minutes the hosts were in front from a corner. Devlin went up for it with Scott Bain and the Dundee keeper was unable to collect, leaving Bingham with the easiest of finishes.
It was 2-0 within a minute, and Bain couldn’t do anything about this one – a Skondras rocket in off the underside of the bar from 18 yards out.
McCann felt the need to change his line-up before half-an-hour was on the clock, with Nick Ross replaced by Craig Wighton.
Shortly after, Kevin Holt came close with a free-kick and the same was the case for Ali Crawford at the other end.
There was a big blow for Hamilton when skipper Michael Devlin went off with a serious-looking injury on 37 minutes. Massimo Donati was his replacement.
On the stroke of half-time David Templeton danced his way through the Dundee defence and forced a fine save from Bain at full stretch to keep the score 2-0 going into the break.
There was a change for the start of the second 45, with Henrik Ojamaa coming on for Marcus Haber.
McGowan hooked a shot goalward through a crowd of bodies following a corner but Bingham cleared from near the line.
It was 3-0 on 56 minutes when Imrie drilled home a penalty after Templeton had been tripped in the box by McGowan.
Three became four on 76 minutes when Crawford finished off a superb passing move from Hamilton.