Hearts scored with the final kick of their Scottish Premiership season to snatch a draw and end their five-game losing run against Rangers.
With nothing on the line, the sides played out an entertaining match which could easily have had even more goals.
Lawrence Shankland dinked in his 31st goal of a stellar campaign to give Hearts the lead but their awful winless run against Rangers, stretching back four years, looked to continue as the visitors hit three without reply after the break.
First, Ross McCausland scored a beauty to bring them level having skipped away from two players to fire in off a post from distance.
Then Todd Cantwell also used the inside of the post to beat Zander Clark after good play from Cyriel Dessers.
Fabio Silva looked to have wrapped up the win with a powerful drive from inside the box, but in the end a crazy game kept up a frantic pace right to the death.
Dexter Lembikisa's volley at the back post just three minutes after Silva's goal gave Hearts hope in the final 10 minutes, and they capitalised in stoppage time.
A punt up the pitch from goalkeeper Zander Clark was flicked towards the box, and Kyosuke Tagawa slammed in a wonderful volley to make it 3-3.
It means Hearts end a successful season in third 17 points behind Rangers, who in turn ended eight adrift of champions Celtic.
Player of the match - Ross McCausland (Rangers)
Hearts savour comeback, Rangers rebuild - analysis
How often do we see final games with nothing on them turn into madness? That is what unfolded at Tynecastle.
Amid a season of progress at Hearts where they have raised their own bar in terms of points, victories, away wins, and comebacks, the only thing that has evaded them has been a win against Rangers.
They may not have got it, but in its own way coming back from two goals down will have been sweet, given the five previous losses at the hands of the Ibrox men.
Steven Naismith, ably assisted by captain Shankland and his 31 goals, has done a fantastic job in comfortably making Hearts Scotland's third force.
The challenge now is repeating the feat next season while adding in European football until at least Christmas, and their only regret will be failing to turn up in two cup semi-finals against Rangers.
However, they can enjoy their summer.
Regardless of how next week's Scottish Cup final against Celtic goes there will be big changes at Rangers in the close season.
Manager Philippe Clement has said as much, citing this being the end of a cycle. That has been said at Rangers a few times in recent seasons, but now it has to be backed up by action.
Again their squad has come up short in the league, which is what they are ultimately judged on.
The manager's job is to decipher who can play a part going forward and who is not up to it.
Whether they add to their League Cup next weekend at Hampden or not will change the mood around the club, but ultimately not the task of building a competitive team for next season.
What they said
Hearts head coach Steven Naismith: "Outwith all the goals, we played really well. We looked comfortable on the ball. But when we gave up possession cheaply we were punished.
"But we scored some good goals, we show character to keep fighting to the end. It could have gone either way and both teams will think they could have won it if they tightened up defensively."
Rangers manager Philippe Clement: "I'm not happy with conceding three when you have four shots on target against, and scoring three from 10 shots on target.
"It's a game you need to win. So it's disappointing in the last two seconds to concede a goal like that.
"Those are the lessons to take with a young squad and players playing out of position because of the circumstances."
What's next?
Rangers face rivals Celtic in next Saturday's Scottish Cup final live on BBC One Scotland and iPlayer (15:00 BST), while Hearts head for their holidays.