Goals from Jamie Walker, Callum Paterson and Ryan Stevenson cancelled out Niall McGinn’s opener, but the match turned in favour of the visitors after Barry Robson was sent-off.
Hearts should have taken the lead when Kevin McHattie found the unmarked Stevenson at the back post, but he shot straight at Jamie Langfield.
Aberdeen responded to that let off by taking the lead when Robson’s corner from the left dropped to McGinn (26) to smash the ball past keeper Jamie MacDonald.
Peter Pawlett almost doubled the advantage as he slipped the ball inches wide of the far post after he was set up by Robson’s brilliant reverse pass.
Hearts survived again when Jordan McGhee appeared to handle a Pawlett strike on the line, but no penalty was awarded by referee Iain Brines.
Moments later Brines did point to the spot when McGhee handled McGinn’s cross, but the latter missed the opportunity to double the lead when MacDonald turned his penalty round the post.
The situation continued to deteriorate for the hosts when Robson (55) was dismissed on a second yellow when he clattered Jason Holt just inside the Aberdeen half.
Hearts substitute David Smith had a shot turned against the bar by Langfield before Walker (66) drifted into the centre of the box at a free-kick and flicked the ball past the exposed keeper before tapping over the line.
Walker then turned provider after working his way down the flank and delivering the ball to Paterson to blast home 16 minutes from time.
Aberdeen were caught on the break in the dying seconds as Stevenson raced through to fire past Langfield and high into the net.