Ryan Conroy and Carlo Monti found the crossbar for Championship side Dundee within the opening 11 minutes but it was the League One visitors who broke the deadlock from the penalty spot just before half-time, Iain Campbell converting after Declan Gallacher fouled Chris Templeman.
Dundee were level soon after the restart through Jim McAlister but the hosts suffered a setback midway through the second period as midfielder Kevin McBride was given his marching orders for a second bookable offence.
Stuart Malcolm's extra-time dismissal for a second yellow card of his own levelled the numbers up and, just as penalties loomed at the end of 120 minutes, MacDonald, who had earlier headed against the bar, found the net with a match-winning free-kick.
- Sports & Recreation
- Iain Campbell