St Johnstone scored two late goals to beat Aberdeen and consolidate fourth place in the Scottish Premiership.
Adam Rooney’s early shot for the Dons was held by Alan Mannus and Kenny McLean later headed wide of the Saints goal.
The visitors took the lead against the run of play when Danny Swanson netted from an indirect free-kick inside the penalty box.
And Swanson set up Craig Thomson to fire in St Johnstone’s second.
Precious points in Euro pursuit
Tommy Wright’s side move six points clear of Hearts and to within six of Rangers, who lost heavily to league winners Celtic earlier in the day.
Derek McInnes’s Dons remain nine points ahead of Rangers with four games to go.
The sides finishing second, third and fourth will enter next season’s Europa League qualifiers and Aberdeen, who have reached the Scottish Cup final, can finish no lower than third.
This victory encapsulates perfectly the good work that Wright and St Johnstone have done over the past four years.
They were far from their best and barely tested Joe Lewis in the Aberdeen goal, but with 12 minutes to play, Lewis saved from young substitute Thomson before Ryan Jack tapped the ball back to his keeper, who picked it up.
Swanson received the indirect free-kick on the left from Liam Craig and smashed the ball into the reverse corner of the net for his 14th goal of the season.
It came after the Perth team kept their hosts at arm’s length for large chunks of the game.
Kenny McLean has had a fine season, but he should have put the Dons ahead with chances either side of half-time.
Saints’ victory was sealed with a swift counter-attacking move. Swanson this time teed up David Wotherspoon’s replacement Thomson, who still had plenty to do but hammered home to guarantee the points would go back to McDiarmid Park.
Second not done yet for Dons
Aberdeen knew a win would all but seal second spot, however, this will keep Rangers’ faint hopes of usurping the Dons alive for another week at least with the two still to play in Glasgow before the end of the season.
Worryingly for McInnes and the Dons fans, the team has tailed off badly in all of his four previous seasons with just one win post-split in each campaign.
The spectre of the cup final against Celtic and the fact the pressure was off thanks to Rangers’ derby capitulation at Ibrox may have played a role in an under-par performance.
However, McInnes will be frustrated at a second straight home defeat when – like against Rangers three weeks ago – they arguably did not deserve to lose.
The Dons travel to face Hearts next in the capital before hosting champions Celtic, meaning the worst case scenario could see Rangers go to within three points of them before the teams meet at Ibrox in their penultimate fixture.
Aberdeen manager Derek McInnes: “The first goal is always really important against St Johnstone. I think it’s a really poor decision from the referee to declare that a pass-back and they’ve taken full advantage.
“Once we go behind, we throw bodies forward and we get done on a counter-attack, which can happen.
“You can see how difficult the pitch is in terms of trying to get any flow to our game.
“We probably didn’t do enough to get ourselves in front, but we certainly didn’t look like losing it.
“I can’t be too hard on the players. They put a lot into it, but it’s a reminder that we have tough games post-split and we need to make sure our level of performance is better than it was today.”
St Johnstone manager Tommy Wright: “It was windy and blustery and the pitch is a bit uneven, so it wasn’t a game of beauty, but the result is the important thing for us at this stage of the season.
“There were moments of quality from us in the lead up to the back-pass being given [for Danny Swanson’s free-kick goal] and the goal from the counter attack and, on that basis, we deserved the win.
“We’ll play a lot better with the ball, but one thing we do when we’re not playing particularly well is grind it out.
“It’s up to the opposition to break you down and I don’t think Alan Mannus has had a save to make all game.”