Paul Kane's 71st-minute header enabled the Perth club to beat Kilmarnock to third place in front of a capacity 10,000 crowd on the last league afternoon of the Scottish season.
The St Johnstone manager, Sandy Clark, was exultant, saying, "This is a great reward for a provincial town like Perth to be able to see European football after so long."
A 1-1 draw for disappointed Kilmarnock at champions Rangers would have been enough, if St Johnstone had not scored their late winner. Yet Kilmarnock might still qualify for Europe.
They are top of Scotland's Fair Play league. If Uefa confirm their intention to reward Scotland as the leading Fair Play nation in Europe, Kilmarnock will qualify.
Their prospects at Ibrox looked bright after Kevin McGowne delivered a 41st-minute equaliser after Gabriel Amato had put Rangers ahead in the sixth minute.
With next Saturday's Cup final at Hampden Park against Old Firm rivals Celtic in mind, Rangers manager Dick Advocaat found much to criticise in his team.
"It was not a good way to end the season and 48,000 fans were entitled to see better," the Dutchman said. "We cannot show that lack of commitment against Celtic. We were terrible."
Celtic, runners-up to Rangers in the league, won 2-1 at Dundee United. Teenage striker Mark Burchill added to his growing reputation with goals in the 34th and 36th minutes.
But there was bad news both for Celtic and the Scotland coach Craig Brown when World Cup midfielder Craig Burley was taken off on a stretcher. A knee injury may need surgery, and Burley will miss the Cup final and Scotland's European championship qualifiers against the Faroe Islands and the Czech Republic next month.
Dundee United striker Billy Dodds gave his international hopes a boost, however. A 63rd-minute penalty was his 16th league goal of the season, though Celtic's Henrik Larsson tops the scoring chart on 28.
Hearts won 5-2 at struggling Aberdeen with Gary McSwegan contributing a hat-trick to ensure sixth place for the Edinburgh club. Aberdeen replied through Jamie Buchan and Eoin Jess as their season finished on a bleak note in eighth - 16 years ago, Alex Ferguson led them to the European Cup Winners' Cup.
Dunfermline, already destined for relegation, lost 2-1 at home to Motherwell. Douglas Ramsay struck the winner to leave Motherwell in seventh place.Reuse content