The game looked to be heading to in extra-time when McKendrick ordered a Stevie May free-kick to be taken again in the third minute of added time for encroachment by Greenock forward Nacho Novo who was booked for his troubles.
May's second effort from 25 yards was spilled by Morton keeper Nicolas Caraux and McDonald pounced to bundle the ball over the line to send the visiting fans into raptures and the home supporters into rage.
Saints go to into the draw on Thursday with Inverness, Aberdeen and Hearts.
Ton manager Allan Moore was so angry he refused to speak to the media afterwards but Wright, who revealed defender Frazer Wright will go for an X-ray on a shin injury in the morning, said: "He was too close to the ball, that's what the players were saying I haven't seen it.
"Nigel Hasselbaink was booked for leading with his arm and another player wasn't so there are things given and not given.
"Allan will have a different perspective but if he is too close to the ball he is too close to the ball and the referee has to give it.
"If a referee somewhere else doesn't give it, is irrelevant. They have a difficult job to do. I think they handled the game well.
"May made it really difficult for the keeper but we had Gary McDonald and another player showing a bit of desire to get on the follow up so I was really pleased."
- Sports & Recreation
- Frazer Wright
- Nacho Novo