Hearts looked destined for the Scottish Premiership drop after Willo Flood had put Aberdeen in front in the 74th minute - just after Danny Wilson had been sent off for a second bookable offence on Adam Rooney.
But Hamill levelled from the penalty spot with just three minutes left after Shaleum Logan brought down Callum Paterson in the box.
Locke admitted he was worried that Sunday's 2-0 win over Hibernian might have taken too much out of his team but he was delighted with their response.
"That was obviously a worry, the physical side of things, but you can see they are getting better physically," said Locke, whose side are 18 points behind St Mirren with six games left ahead of Saturday's visit to Partick Thistle.
"I said on Sunday they are improving and getting stronger and I think you can see that again.
"They acquitted themselves brilliantly, especially in the second half, against a top team, even when we went down to 10 men.
"It would have been easy to put the heads down but as usual we got the response we were looking for."
Aberdeen manager Derek McInnes felt his team should have killed the game off - although he was not convinced referee Kevin Clancy was correct with the penalty decision.
"I'm disappointed because it was game we dominated until the last five minutes," he said.
"We had real opportunities to get the second goal. We have to make sure we see that off.
"I'm not convinced it is a penalty. I watched it again and I'm not convinced the referee is in a good position to see it, and he has got to be 100 per cent sure.
"Shay should deal with the first clearance better but I think Paterson throws himself into Shay's body."
McInnes explained why Barry Robson sprinted past him down the tunnel around the hour mark - 10 minutes before he was substituted.
"He has got some sort of stomach upset," McInnes said. "The first I was aware of it was when he ran by me. It's the quickest he's moved all season.
"When he went back on he was looking a bit leg-weary. We were thinking of
making a change anyway and Cammy Smith gave us a spark, but Barry obviously had the runs and had to come off."