Aberdeen 0 St Johnstone 1
Chris Kane upstaged Aberdeen captain Russell Anderson's last game when he netted his first St Johnstone goal with his first touch of his side's crucial 1-0 victory at Pittodrie.
The 20-year-old ran onto a pass down the right channel from fellow substitute James McFadden before slotting underneath Scott Brown, just seconds after coming on as a 70th-minute substitute.
The only goal of the game earned St Johnstone a fourth-place Scottish Premiership finish and will also secure a hat-trick of Europa League adventures if Inverness win the William Hill Scottish Cup.
Saints had given Anderson a guard of honour along with the home players as the retiring 36-year-old made his first appearance following nine months out with knee problems.
Dundee-bound Nicky Low and Joe Shaughnessy, who this week signed a pre-contract deal with St Johnstone, were also afforded farewell starts but the sentiment in the team selection did not continue into the game as Aberdeen threatened to knock their visitors out of the top four.
With Dundee United opening the scoring early in their comfortable derby win over Dundee to temporarily leapfrog Saints, there was tension in the large visiting support, which boosted a crowd of 16,389.
Referee Willie Collum dismissed an early St Johnstone penalty appeal when Danny Swanson got past Cammy Smith and went down claiming his heels had been clipped.
Saints dominated possession in the opening half hour but the only chance they created came when Michael O'Halloran nodded the ball past Anderson and shot into the side netting.
The visitors needed Steven Anderson's positional sense to stop Cammy Smith forcing the ball home after Low's cross and a touch of desperation crept into the St Johnstone ranks when Steven MacLean earned himself a yellow card for diving inside the Aberdeen box.
Jonny Hayes threatened to worsen the visitors' situation three times towards the end of the first half.
The Irish winger skipped past two challenges and fired just wide of the far post, then shot straight at Alan Mannus under pressure after being sent clear on the break by Niall McGinn. He came closer still when Mannus pushed his powerful 20-yard strike on to the post.
St Johnstone had a let-off seven minutes into the second half when McGinn's first-time pass released Smith but he was stopped in his tracks by Tam Scobbie's sliding tackle with Collum waving play on despite loud appeals for a penalty.
Saints soon had a great chance when Liam Caddis crossed following a quick free-kick but O'Halloran could not react when the ball reached him four yards out and it bounced into Scott Brown's hands.
Saints brought on the experience of Brian Graham and McFadden while the Dons introduced the youth of Lawrence Shankland and Scott Wright.
The Saints substitutes linked up quickly when McFadden's diagonal ball allowed Graham the chance to run and shoot from 20 yards but he fired just wide.
Collum showed his ruthless side by brandishing a yellow card to Aberdeen skipper Anderson for a foul on Murray Davidson before another Anderson found himself in trouble. The Saints defender misjudged Hayes' long ball but Wright could not get hold of his shot.
The game was finely poised when McFadden's pass sent Kane in behind and the forward added to the five goals he netted on loan at Dumbarton earlier this season.
Aberdeen pushed hard for an equaliser and Shaughnessy nearly cost himself a chance to play in Europe next season when he hit the target with a powerful long-range effort but Mannus tipped it over.