Substitute Hendry had been on the field for just three minutes when he pounced to crash home the 89th-minute winner in a topsy-turvy contest.
After nine games without a victory, Saints manager Tommy Wright was rewarded for a dominant display.
Saints remain at the foot of the table, but in a tightly-packed league they closed the gap to a point on nearest rivals Hibernian.
A teasing 15th-minute Wotherspoon cross just needed a touch but Stevie May could not stretch far enough to provide a close-range finish.
Three minutes later Hamilton rode their luck when Davidson's 20-yard shot crashed back off the crossbar.
But yet again Saints found themselves a goal behind in the 25th minute after early domination, falling victim to a slick Hamilton counter-attack.
But midfielder Wotherspoon marked his milestone appearance for his hometown team by ramming Saints level in the 36th minute after his initial effort from 16 yards had been blocked.
With the interval looming, Wright missed from eight yards with the target at his mercy.
The Englishman had played in Matty Kennedy and the striker's rising shot was diverted by Fon Williams, only for Wright to blaze the gilt-edged chance over the bar.
Saints were denied by the woodwork again 11 minutes after the break, when Wotherspoon's crisply-struck 25-yard strike rebounded from an upright and May curled the loose ball wide from the edge of the box.
The St Johnstone midfielder persevered, though, and on the hour he latched onto a May pass, sold the defenders a dummy and sent a precise 16-yard right-foot shot curling into the far corner.
But after Davies drew Accies level from the spot, Hendry smashed in the winner.