Jamie Hamill converted a late penalty as Hearts drew 1-1 with Aberdeen at Tynecastle on Wednesday night.
Defeat would have condemned Gary Locke's men to the drop and they fell behind when Willo Flood fired home a 74th-minute free-kick after Hearts skipper Danny Wilson had been sent off for a second booking.
But, with three minutes left, Shaleum Logan was penalised for a challenge on Callum Paterson and Hamill made no mistake from the spot.
The point was still enough to take Aberdeen back into second place in the Scottish Premiership, ahead of Motherwell on goal difference.