Hearts recovered from the loss of a man and a penalty equaliser to defeat Aberdeen at a vibrant Tynecastle.
Jamie Walker gave the hosts the lead against the run of play on 18 minutes.
The Dons levelled from the spot through Niall McGinn after a professional foul on Calvin Zola had Kevin McHattie sent off.
But the ten men struck again with three minutes to go through Jordan McGhee’s back-post header.
The victory saw Hearts reduce their 15-point penalty for going into administration to minus eight.
There was a minute’s applause pre-match to mark the passing of former Hearts winger Jonny Hamilton and former Dons keeper Fred Martin.
Aberdeen had the first sight of goal in the third minute with Scott Vernon beating the offside trap but scuffing his shot at home goalkeeper Jamie MacDonald.
Then Hearts took the lead. Walker seized on slack defending before driving home from 20 yards into the bottom right corner, leaving Nicky Weaver helpless.
It was the second week running that the midfielder netted, after rescuing a point at Partick Thistle.
Vernon found himself through again a couple of minutes later, but with the Hearts defence sleeping the Mancunian put his effort wide.
McGinn, Peter Pawlett and two Clark Robertson headers all came and went as the hosts went in ahead at the break.
Dons manager Derek McInnes changed it early into the second half with Vernon hooked for Zola.
It paid dividends not long after as McHattie brought Zola down in the box. The left-back was sent off and McGinn converted the resultant penalty to make it three goals so far this season.
Pawlett was then booked for diving after a Walker challenge in the box, angering the 2,500-strong travelling support.
McInnes went for the win, replacing Robertson with Gregg Wylde, but it was the ten men who won it three minutes from time.
Weaver came and missed a long free-kick and 17-year-old substitute McGhee headed home his first senior goal. McInnes and Hearts’ assistant boss Billy Brown were sent to the stand in the aftermath.