Barry Nicholson kept Aberdeen in control of their UEFA Cup destiny with a dramatic late strike at Tynecastle.
Nicholson cancelled out a first-half strike from Andrius Velicka and kept his team's four-point advantage in third place.
Booked just a couple of minutes before his goal, he was shown another yellow card and sent off after his goal celebration.
Hearts weathered early Aberdeen pressure but came back to claim the lead after 14 minutes.
Zander Diamond needlessly gave up possession and Roman Bednar fed Velicka, who produced a clinical finish under the body of Jamie Langfield.
Aberdeen hit back with Darren Mackie looking dangerous, but Hearts were well-organised at the back.
Richard Foster was just off target with an effort after Saulius Mikoliunas had been careless with his clearance.
Jamie Smith then tested Craig Gordon with a stinging shot after good work from Lee Miller.
Mackie was then just inches away from connecting with the ball in front of goal after Miller had headed the ball back.
Miller beat Gordon with a 34th minute header only to see the ball crash against the post.
Hearts finished the first half strongly and Christophe Berra headed into the arms of Langfield.
Both sides made changes at half-time with Hearts taking off Tomas Kancelskis and Aberdeen replacing Andrew Considine - both players having picked up bookings.
Hearts came close to a second after an hour when Bednar's shot across goal just eluded substitute Michal Pospisil at the back post.
Langfield then had to be alert to snatch the ball away from the feet of Bednar after Laryea Kingston had played the ball through.
Mackie should have equalised in the 65th minute when he was through on Gordon but mis-kicked and the ball finished tamely wide.
The Aberdeen striker was then unlucky when he tried to guide a shot into the corner of the net but Gordon saved well.
It was end-to-end stuff and Andrew Driver was unlucky with a shot on the turn which was just a foot too high.
Nicholson then silenced Tynecastle when he shot the ball past Gordon after being set up by Craig Brewster with just a minute left.