Nigel Hasselbaink headed the first while Stevie May added a second shortly after the break to give Saints a deserved three points.
Hasselbaink broke the deadlock on 29, as the Dutchman met Chris Miller’s defelected pass to find the bottom left-hand corner of the net from 10 yards.
It was a goal the visitors certainly deserved, having created most of the chances during the opening half-an-hour at Tynecastle.
May had headed narrowly wide early on, while Hasselbaink forced a good save out of Jamie MacDonald with the game still goalless.
The hosts finally found their feet during the latter stages of the first half, as Ryan Stevenson twice missed the target from outside the box, with Jordan McGhee going close on 38.
But any chance of a Hearts revival was cut short early in the second half as Saints doubled their advantage.
With 52 minutes on the clock, May pounced on a rebound to superbly curl the second into the top right-hand corner of the net, after which there was no stopping St Johnstone from claiming their first league win on the road since early May.
Dylan McGowan and Danny Wilson did their best to reduce the deficit, going close with a succession of headers and – although Hearts fared better towards the end regarding possession – they were unable to create too many problems for Alan Mannus in the away goal.
The win takes Tommy Wright’s team into fifth spot in the table.