Accies had Alex Gogic sent off after half an hour and Saints made the extra man count with two goals in the last 15 minutes from Kyle McAllister and Kyle Magennis.
The win moves Oran Kearney's side to within a point of Brian Rice's team going into the last weekend of the season. Hamilton are at home to St Johnstone on Saturday and St Mirren, who occupy the relegation play-off place, travel to relegated Dundee.