Hearts will be in the Champions League qualifiers next season for the first time after a tension-filled 1-0 win over Aberdeen in the Bank of Scotland Premier League at Tynecastle.
A Paul Hartley penalty in the second-half was all that separated the sides at Tynecastle and ensured Hearts finished above Rangers as runners-up behind champions Celtic.
And the Edinburgh club's success also sparked celebrations in the tiny Scottish borders town of Gretna.
Amazingly the Second Division champions will now play in next season's UEFA Cup thanks to their qualification for the Scottish Cup Final where they will play Hearts at Hampden on May 13.
The game itself on Wednesday was far from a classic and though the home side were the better side throughout they struggled to break down a plucky Aberdeen side who are chasing fourth place in the SPL.
However, in the 50th minute Hearts were awarded a penalty after a blatant handball by Dons defender Zander Diamond.
Hartley stepped up to the spot and drove a powerful right-foot
shot low into the left-hand corner of the net.
And any chance of Aberdeen getting back on level terms, to take the fight for second place to the last game of the season, were finished after the sending off of Scott Severin in the 79th minute.
Pipping the Ibrox club to second place in the SPL caps a remarkable topsy turvy season for the Tynecastle club under controversial Lithuanian owner Vladimir Romanov.
No less than four men have been handed the reigns of the first-team squad during the current campaign.
First the highly respected former Ipswich boss George Burley guided the Edinburgh side to top of the table by going 10 games unbeaten.
There had been rumours that the manager was unhappy with interference from Romanov over team selections but it was still a huge shock when the Lithuanian millionaire sacked Burley in October.
A week later Hearts chief executive Phil Anderson was sacked and chairman George Foulkes resigned in protest and the Tynecastle club looked in crisis.
Hearts coach John McGlynn took control of first team matters and guided them to three wins and a loss before making way for Graham Rix in November.
The appointment of the former Arsenal star and Chelsea coach was a controversial move and he got off to a poor start with three draws, one defeat and only one win in his first five games which allowed Celtic to open up a gap at the top of the SPL.
However, Rix recovered and led Hearts to the semi-final of the
Scottish Cup and took them into pole position in the race for second place with a six-point lead over Rangers.
This was not good enough for Romanov and he duly sacked the
Englishman and promoted fellow countryman Valdas Ivanauskas into the head coach role, in a caretaker basis, on March 22 and he led them to a second-place finish.
Arguments will continue as to where Hearts would have finished if they had kept Burley in charge but at the end of the 90 minutes the fans packed into Tynecastle showed their delight with what they had achieved.