The home side had raced into a 3-0 lead inside 30 minutes only for Motherwell to haul themselves level on the back of a James McFadden brace but Henrik Ojamaa saw red before McKay pounced to clinch it.
Motherwell failed to deal with an early free-kick and McKay (3) was on hand to prod home his 25th goal of the season.
Richie Foran hit the post before Andrew Shinnie (25) did well to work some space 12 yards out and slot the second.
Two minutes later Shinnie scuttled down the right before teeing up predator-supreme McKay (27) to extend the advantage.
McFadden (36) managed to restore a modicum of self-belief to the shell-shocked visiting ranks with a decent hit from 20 yards.
Michael Higdon (49) then increased the anxiety in the home ranks after Chris Hogg had fouled Ojamaa in the box, slotting in his 27th of the season from the spot.
The drama was unrelenting as Darren Randolph denied McKay from the penalty spot and with Well quickly back on the offensive, McFadden (64) slotted his second of the afternoon to level the scores.
Shaun Hutchinson made a great challenge to deny McKay before Ojamaa was ordered off for his second yellow card.
But McKay (84) was not be denied as he latched on to a loose ball after Randolph could only parry to claim the match ball and victory.