Stevie May was allowed to retake a stoppage-time free-kick for St Johnstone and his second effort was spilled by Nicolas Caraux before McDonald turned in the loose ball.
Morton went close in the early stages when Mark McLaughlin’s header drew a save from Alan Mannus, but St Johnstone also showed their threat when David Wotherspoon fired wide.
The hosts were holding their own against the top-flight side and Dougie Imrie’s long range effort tested Mannus, while at the other Nigel Hasselbaink dragged the ball past the post.
Both sides continued to push for a breakthough and Stephen Stirling was denied by Mannus before David Wotherspoon hit the post with a free-kick.
But McDonald would have the final word in the dying minutes, despite angry protests from the Morton players and their manager Allan Moore.