Steve Clarke is set to leave Kilmarnock with a farewell gift of a third-place finish in the Ladbrokes Premiership after Eammon Brophy's late penalty sealed a 2-1 win over Rangers at Rugby Park.
With the Killie boss expected to be named the new Scotland manager this week, Clarke was hoping to leave on the back of the Ayrshire outfit's highest league finish since 1966.
And Clarke – watching from the stands after receiving a ban for criticising referee Steven McLean – got his wish as Brophy drilled home from the spot in the 89th-minute.
The hosts got off to a perfect start when Chris Burke fired home against his old side only for Alfredo Morelos to turn up the tension with his 30th goal of the season – and his 10th against Killie – midway through the second half.
But Brophy kept his nerve late on to ensure his team – with or without Clarke – will be heading abroad for their first European adventure in 18 years next term.
The home side had supporters almost filling three sides of Rugby Park after deciding to slash Rangers' ticket allocation in half.
And they were in merciless mood as they cheered Joe Worral's every touch early on as the centre-back returned for the first time since his blunder handed Clarke's side victory back in January.
The Nottingham Forest loanee feared history was repeating itself when he got in the way of Andy Halliday's pass back but Brophy could not take advantage.
Killie defender Stuart Findlay also looked on with relief after being robbed by Daniel Candeias. Morelos burst through but saw his shot parried by Jamie MacDonald before Candeias then fizzed the rebound against the crossbar.
But it was Glen Kamara at fault as Killie stuck after nine minutes. Dallying on the ball, the midfielder allowed Youssouf Mulumbu to steal possession and then spray a wonderful ball over the top for Burke, who calmly steered past Wes Foderingham for the opener.
Gers looked for a quick response. Ryan Kent danced into the box but goalkeeper MacDonald made a brilliant reflex save before the ball bounced just wide after hitting Kirk Broadfoot's shins while Morelos fired into the sidenetting.
But for all the possession Steven Gerrard's team enjoyed, they were doing little with it.
It was Killie who should have scored again two minutes after the break when the ball broke to Mulumbu in the box but Foderingham was out in an instant to punch clear at his feet.
Rangers were left frustrated again on the hour mark as referee Willie Collum turned down handball appeals against Burke in the box.
The travelling support rose to welcome 17-year-old Dapo Mebude as Gerrard handed the academy winger his debut in place of Candeias.
And the Gers faithful were off their feet again as Morelos became the first Ibrox player in 10 years to hit 30 goals in a season in the 67th minute.
Kent's reverse pass found Ryan Jack in the box, with his turn and pass picking out the Colombian to fire past MacDonald from seven yards out.
MacDonald had to be replaced by back-up stopper Devlin Mackay as he limped off as a result of an earlier clash with the Gers goalscorer.
Morelos' strike had deflated the earlier party mood and there was further agony for the home fans when substitute Liam Miller was ruled offside as he fired home at the back post.
The visitors also had to change their goalkeeper as Foderingham moved aside, handing another debut to former Liverpool youngster Andy Firth.
Killie sensed their chance and it came with 60 seconds left when Borna Barisic pulled down Stephen O'Donnell in the box.
Rugby Park went wild as Brophy's penalty escaped Firth's reach but the nerves returned when Collum added six minutes of stoppage time.
However, Kilmarnock held firm to ensure Clarke leaves with a legacy to be proud of.