After a poor first half, home skipper Steven Anderson broke the deadlock for Saints before Danny Swanson added a second with a penalty.
A spot-kick at the other end by Rory Loy pulled one back for Dundee in the 88th minute but it was too late to avoid a fifth successive defeat.
Paul Hartley’s team are still without a win since the opening day of the league season. The manager admitted at full-time that yesterday’s second-half display had not been good enough and he confessed they now face a huge match with second-bottom Patrick Thistle on Wednesday night.
“We are in a position where we don’t want to be and we have to turn it quickly. That has to start on Wednesday,” said the manager.
“Partick Thistle is a vital game for us now. We are ten games in, it’s not been good enough and that can’t become a habit now.”
After a placid start by both sides, Dundee should have taken the lead in the 13th minute.
Faissal El Bakhtaoui flicked on a Kevin Gomis pass to let Paul McGowan scamper free into space down the right. The midfielder’s square pass was perfect for Yordi Teijsse but the striker’s tame shot from 14 yards was straight at Zander Clark in the Saints goal.
Clark was called into action eight minutes later to push a Tom Hateley free-kick behind and to grab Teijsse’s header from the resultant corner.
Dundee’s chances sparked the hosts to life but Chris Kane could not get a flick on Murray Davidson’s low ball following a scramble that saw the Perth men appeal for a penalty when Steven MacLean went down in the box.
There was little change to the scrappy pattern of the game after the interval, but St Johnstone increasingly gained the ascendancy as they upped the tempo of their attacks.
The opener eventually came in the 62nd minute. Liam Craig’s left-foot free-kick from the right curled menacingly into the heart of the Dundee box and Anderson stretched to volley in at the back post.
Dundee could not get going in the final third and their task was made twice as hard when Saints netted a second with 15 minutes remaining. Referee Andrew Dallas judged that Gomis had barged MacLean just as he rose for a header and pointed to the spot. Swanson swept in calmly.
There was almost a third in the 82nd minute when Swanson’s superb chipped pass found Michael Coulson but the substitute’s header crashed back off the crossbar.
Anderson’s careless push on Teijsse allowed Loy to pull one back from the spot with two minutes left but the visitors left it too late and could not find an equaliser.
The result moved St Johnstone above Rangers in the table into fourth and level on points with Hearts, and manager Tommy Wright said it would have been a “travesty”had his team not held out for all three points.
“It was definitely more nervy than it should have been at the end,” explained Wright.
“I reckon it would have been a travesty if they had equalised. It was crazy, I don’t know what Ando [Anderson] was doing [in conceding the late penalty]. He was getting a bit of a ribbing in the dressing room.
“It was a silly thing to do and caused ourselves a nervy two of three minutes when we shouldn’t have. But they’ve seen it out and we’ve got the win which we did deserve.”