Mickael Antoine-Curier finished off a slick counter-attack with a cool finish to put the Accies ahead after 32 minutes.
Aberdeen midfielder Gary McDonald equalised with 15 minutes left before James Wesolowski scored his first Hamilton goal five minutes later.
Aberdeen made two changes from the side which lost 3-0 at Celtic Park last weekend with skipper Mark Kerr replacing the suspended Jerel Ifil, while Chris Maguire was preferred to midfielder Derek Young.
The visitors, missing striker Leon Knight who was suspended for his part in a tunnel brawl which marred last weekend's 2-1 win over Hearts, kept with the same starting XI.
The Dons started brightly with Accies goalkeeper Tomas Cerny relieved to watch a deflected Charlie Mulgrew free-kick from 30 yards go past the post for a fruitless corner.
Mulgrew then turned provider when his pin-point corner found Chris Maguire, whose glancing header was cleared off the line by Australian full-back Trent McClenahan.
A searching pass from Mark McLaughlin released Antoine-Curier but the Frenchman's effort was comfortably gathered by Jamie Langfield after 21 minutes.
Aberdeen were forced to make an early change when Peter Pawlett limped off and was replaced by Sone Aluko, making his first appearance in more than a month following a stomach injury.
Hamilton took a surprise lead after 32 minutes with a quick counter-attack when Richard Foster could only head Simon Mensing's cross into the path of James McArthur, whose mis-hit shot fell to Antoine-Curier to slot past Langfield for his fifth goal of the season.
Lee Miller became the first Dons player to face Mark McGhee's new community service punishment after he was booked for a reckless challenge on Hamilton goalkeeper Cerny which sparked a melee in the box.
Wesolowski should have scored just before the break following a series of errors in the Dons defence but the midfielder dragged his shot wide.
Hamilton's substitute goalkeeper Sean Murdoch came on at half-time for Cerny, who had been struggling following Miller's robust challenge.
The pressure on the Accies defence was relentless but shots from Kerr and Mulgrew were blocked by last-ditch tackles as the home support became increasingly frustrated.
Both sides freshened things up with Hamilton introducing Marco Paixao at the expense of Guillaume Beuzelin and Davide Grassi replacing Michael Paton for the Dons.
And Grassi did not waste much time in joining Miller for community service after being booked for a mistimed tackle on Mensing after 63 minutes.
Gary McDonald had a great chance to get his side back on level terms in the 72nd minute but the former Oldham Athletic player blasted well over the bar after neat work by Aluko.
But the midfielder made no mistake two minutes later when a slack clearance fell to him on the edge of the Hamilton box and he kept his composure to slot the ball into the bottom corner.
However, Aberdeen's jubilation was short-lived as Hamilton went back in front five minutes later when Antoine-Curier laid the ball into the path of Wesolowski to drill past Langfield.
Aberdeen were forced to play the final stages with 10 men after Maurice Ross picked up an injury but continued to press forward in search of a second equaliser.
But when substitute Tommy Wright saw his half-hearted appeals for a penalty turned down after McLaughlin looked to have used a hand to block his shot, the visitors knew they were taking home all three points.