James Lister opened the scoring for the visitor's after 12 minutes when he met Scott Agnew's cross and headed the ball firmly past home keeper Kevin Cuthbert.
Ziggy Gordon, who had passed a fitness test just before the game, tested Stephen Grindlay with a decent effort but the keeper managed to push the ball wide.
Darian Mackinnon was then denied by Grindlay before May (79) finally made the breakthrough as he fired in from close range after 79 minutes.
May then popped up with five minutes remaining to win the game for Hamilton
when he forced the ball in from Alister Crawford's corner.