The 19-year-old was handed just his second start but repaid manager Pat Fenlon's faith with his sensational strike.
The final Clydesdale Bank Premier League meeting of the sides this season looked set to end in a fourth stalemate after Leigh Griffiths' stunning free-kick two minutes after half-time cancelled out Darren Barr's 44th-minute opener for Hearts.
But Hibs - who are preparing for their second successive final appearance later this month - ensured they retain the bragging rights as they added to their January cup triumph with a second victory over Hearts this season as well as overtaking Gary Locke's men to steal ninth place in the table.
The visitors had Alex Harris and Lewis Stevenson to thank early on as they came up with the last-ditch clearances and the defending was just as desperate at the other end as Jamie MacDonald was forced into action for the first time after 20 minutes.
Hibs midfielder Kevin Thomson then had a half-hearted penalty appeal turned down by referee Steven McLean after tussling with Ryan Stevenson.
The scoring was opend a minute before the break when Ben Williams lost the flight of McHattie's corner towards the back post. While Michael Ngoo saw his point-blank range header stopped on the line by Tom Taiwo, Barr was there to smash home the rebound.
Fenlon had words with McLean going down the tunnel, claiming Thomson had been pushed by Hamill in the build-up to the corner, but replays showed the former Scotland man had slipped.
Griffiths, however, would finally make his mark just two minutes into the second period. A Mehdi Taouil barge on Harris teed up the striker to shoot from 25 yards out and his set-piece effort was simply stunning as it skimmed over the Hearts wall and past MacDonald on its way to the top corner.
A draw looked increasingly likely until Caldwell came up with his decisive strike. Griffiths charged down Hamill's clearance and the ball broke to substitute Scott Robertson before bouncing onto the teenage striker, who swept the ball into the top corner to cue bedlam in the away end.
- Sports & Recreation
- Leigh Griffiths
- Pat Fenlon
- Darren Barr