On-loan debutant Lee Croft opened the scoring in the first half with a fine low finish. But that lead was cancelled out in the second period through a Leigh Griffiths penalty.
However just seconds later wasteful defending allowed Liam Craig to restore the Perth side's lead.
Hibs, displaying admirable character, made it 2-2 through Callum Booth's neat finish.
But the home side failed to defend and the excellent Sandaza found the space to fire home a superb late winner to secure all three points for St Johnstone.
The result moves St Johnstone into fourth place in the Scottish Premier League table and above Motherwell.
Garry O'Connor saw an early effort disallowed for offside, in an early indicator of what would be a tumultuous encounter.
Both sides subsequently exchanged decent chances. Firstly, Sandaza appeared to misjudge the flight of an excellent Dave MacKay cross and his header skewed away from goal.
That was immediately followed by O'Connor taking a wild swing at fresh air from a similar distance.
Midway through the first half St Johnstone goalkeeper Peter Enckleman was finally forced into serious action, palming away a powerful O'Connor shot from the angle of the penalty area.
St Johnstone were next to threaten but Mark Brown saved Sandaza's low shot.
That was a temporary reprieve for the Hibees. Croft, who intelligently drifted off the right-flank to find a pocket of space in the middle of the park, drove a ferocious effort at goal which was blocked by Hanlon.
However the rebound fell kindly to Croft, and his finish was drilled into the corner of the net.
Leigh Griffiths decided to try and prompt a recovery with a decent solo effort as half-time approached. His jinking 40-yard run saw him ride three challenges but his shot trickled wide.
The last chance of a lively first period saw Brown tip a Dave MacKay header over the bar.
The home side had a great chance to equalise early in the second half. Michael Hart's long ball fell to Lewis Stevenson, but the midfielder woefully mis-kicked his effort from eight yards.
Seconds later Marcus Haber broke the offside trap and forced a splendid save from Brown, before Murray Davidson, left unmarked in the box, headed a Liam Craig cross wide.
Brown was being forced to keep Hibs in the contest. Just after the hour-mark Sandaza burst into the area and forced a splendid save from the former Rangers and Celtic stopper.
The home side equalised against the run of play with 20 minutes to play. Steven Anderson hauled back Griffiths in the box, and the on-loan Wolves man slotted the spot-kick into the corner.
Almost straight from the restart the Saints were ahead again, with Hibs' defensive frailties exposed once more.
Liam Craig took advantage of some lethargic play from Stephens to sneak behind the Welshman and fire into the corner of the net.
Griffiths spurned a super chance to make it 2-2 with 10 minutes to play, heading over the bar from point-blank range.
However, the equaliser did come through the unlikely source of Callum Booth.
The 20-year-old latched on to the ball on the left before surging into the box and lashing a right-foot effort into the net.
However, a remarkable encounter still had one twist left, and it was left to the game's star performer to provide it.
Sandaza received the ball on the edge of the Hibs box. His control was terrific, the turn was marvellous, and the finish superb past Brown.