Ross Caldwell curled in a wonderful 90th-minute strike to give Hibernian their first Edinburgh derby win at Tynecastle in four years.
Darren Barr poked Hearts in front on the stroke of half time as keeper Ben Williams messed up from a corner.
But a stunning free-kick from Leigh Griffiths levelled matters early in the second half.
And Caldwell's cool finish from 14 yards lifted Hibs back above Hearts into ninth place in the SPL table.
With little at stake other than local bragging rights, the 300th derby in major competitions was a lively affair, eclipsing the three dreary draws served up in this season's previous league meetings.
Jordon Forster enjoyed a solid debut in central defence and Alex Harris caught the eye with a lively performance on the right wing but it was Caldwell, making just his second start, who was the toast of the Hibs teenagers.
The 19-year-old did not get too many glimpses of goal but staked a claim for a Scottish Cup final place with his excellent winning strike.
The visitors were the brighter side in the opening exchanges, knocking the ball around well in midfield and utilising the pace of the Harris.
However, Pat Fenlon's side needed two good headed clearances to prevent them from falling behind as Williams dropped a corner from Kevin McHattie, with Barr and Michael Ngoo denied by Lewis Stevenson and Alan Maybury inside the six yard box.
Jamie MacDonald got down low to save a first-time shot from Harris after an exchange with Caldwell.
The Hearts keeper made a similar stop from Caldwell's deflected, raking effort from the left edge of penalty box and a panicked clearance from McHattie fell to Harris but the winger could not profit as he too lacked composure.
Griffiths lined up a long-range free kick, bringing to mind his effort that was not seen by the officials crossing the line by some distance in the last meeting of the teams, but this time his fizzing effort was deflected wide by the defensive wall.
Otherwise, Hibs leading scorer was being well shackled by Andy Webster.
Griffiths scored his 100th career goal with an excellent free-kick
In the final minute of the first half, Hearts were awarded a corner when Kevin Thomson knocked the ball out of play under pressure from Hamill.
The Hibs midfielder wanted a foul but appeared to have slipped and his mood turned darker still when the home side took the lead from the resultant set-piece.
Williams was badly at fault as he got nowhere near McHattie's delivery as Tom Taiwo blocked Ngoo's header on the post and Barr was quickest to react as he prodded the ball in from a prone position on the turf.
Hibs were level within three minutes of the second half as Harris was upended 25 yards out and Griffiths stepped up to curl a fabulous free-kick into the top corner.
Harris then flashed a great ball across the face of goal, with Griffiths inches away from connecting.
Hearts responded with a Hamill free kick that had to be clawed away by Williams and a bobbling volley from Walker whizzed narrowly wide from 20 yards.
Paul Hanlon then made a crucial sliding block from a Ryan Stevenson cross that appeared destined for Ngoo in front of goal.
With the clock reaching 90 minutes, substitute Scott Robertson broke into the penalty area from the left to slip a pass to Caldwell and the striker took a touch near the penalty spot before finding the top corner.
The visiting fans went wild and only had to wait a few more minutes to celebrate their first unbeaten season against their city rivals since 2000/01.
Heart of Midlothian
- 01 MacDonald
- 05 Barr
- 06 Webster
- 29 McHattie
- 02 Hamill
- 07 Stevenson
- 10 Taouil (Smith - 80' )
- 14 Walker Booked
- 15 Holt (Smith - 90' )
- 09 Sutton
- 21 Ngoo (Carrick - 73' )
- 13 Ridgers
- 28 McKay
- 19 McGowan
- 12 Smith
- 17 Smith
- 32 B King
- 37 Carrick
- 01 Williams
- 04 Hanlon
- 18 Maybury
- 37 Forster
- 08 Claros
- 16 Stevenson
- 20 Taiwo
- 33 Harris
- 38 Thomson Booked (Robertson - 80' )
- 09 Griffiths
- 29 Caldwell
- 31 Murdoch
- 36 Donaldson
- 07 Deegan
- 14 Wotherspoon
- 28 Robertson
- 10 Doyle
- 24 Handling