May, who spent last season on loan with Accies, grabbed the opener early on in the tie at New Douglas Park.
Gwion Edwards then came off the bench to claim his first goal for the club late on, before May struck again in injury-time.
May was drafted back into the Saints side after coming off the bench as they suffered defeat to Celtic at the weekend.
Hamilton added Tony Andreu and Jon McShane to their own starting line-up as they aimed to add cup success to an impressive start to their league campaign.
But the Scottish Championship leaders were unable to claim a top-flight scalp despite a decent display on the night.
The home side were left reeling when they found themselves trailing with just four minutes on the clock.
Accies could have been back on level terms but were denied by the woodwork when Andreu's effort crashed off the post.
At the other end, Saints were threatening again when Chris Millar squared across the face of goal for MacLean but his shot was touched over by Kevin Cuthbert.
Millar then turned provider for May and his effort was deflected wide for a corner that the visitors failed to capitalise on.
With half-time approaching, Andreu tried his luck with a drive that fizzed just past the upright as Saints headed into the interval with their narrow advantage intact.
The Perth side looked determined to add to their lead after the restart and Nigel Hasselbaink powered his way into the box only for his shot to be blocked by Cuthbert.
Saints continued to struggle to break down the stubborn resistance of the home side, with Accies still in with a chance of salvaging the tie as the match entered the final 15 minutes.
A long free-kick punted into the box was met by the head of Mikey Devlin but he could not keep the effort down.
With Saints beginning to look nervous, Andreu then whipped a tempting ball into the goalmouth but, this time, Devlin sliced wide of target.
But there was no way back for Accies when substitute Edwards picked up the loose ball from a slack back-pass and bundled home from close range to secure the win for the visitors with four minutes to go.
May then put the gloss on the win with a superb 25 yard strike deep into injury-time.
- Sports & Recreation
- Gwion Edwards