His close-range header midway through the second half was all the separated the teams and even a late red card for Iain Davidson, for an off-the-ball incident, could not ruin Dundee's day.
Dundee controlled long spells of the first half but did not create much against Alloa's well-organised rearguard.
It was Alloa who could have taken the lead when Kevin Cawley was through, but Kyle Letheren was alert to save.
The goalkeeper also did well to block a shot from Ryan Caddis early in the second half, before MacDonald headed the decisive goal.
Hamilton Academical were nudged off the top as Dumbarton beat them 2-1 win at Bet Butler Stadium.
There was an early scare for the home side when Ali Crawford's terrific effort from outside the area struck the underside of the crossbar.
But Garry Fleming scored with a low shot to give the hosts an 11th-minute lead and Bryan Prunty would have added a second, had it not been for the awareness of Kevin Cuthbert.
James Keatings equalised for Hamilton with a simple finish from Mikhail Antoine-Curier's low cross but Dumbarton won prevailed thanks to the untidiest of goals.
Hamilton failed to clear a corner and, in the scramble that followed, Andy Graham poked home what proved to be the winner.
A pulsating Fife derby between Raith Rovers and Cowdenbeath ended 3-3 with Kane Hemmings striking a last-minute equaliser on Jimmy Nicholl's return to Kirkcaldy.
Greg Stewart gave Cowdenbeath the lead but Dougie Hill headed an equaliser before half-time.
Calum Elliot then put Raith ahead, only for Hemmings to level the scores from the penalty spot.
Callum Booth's late penalty, following Tom O'Brien's foul on Hill, looked to have sealed the points for the Kirkcaldy side but Hemmings' 90th-minute equaliser gave Cowdenbeath a valuable point in their battle to stay clear of the automatic relegation spot.
Kenny Shiels' first official match as Morton manager ended in disappointment at Falkirk won 2-0 at Cappielow.
Morton seldom looked secure at the back over the 90 minutes and Falkirk took full advantage.
Conor McGrandles, Rory Loy and Mark Millar all came close in the first half and Morton's best response came from Reece Hands.
Kieran Duffie headed the opening goal in off the underside of the crossbar six minutes into the second half from Millar's corner.
Loy scored the decisive second from the penalty spot after Tomas Peciar fouled Phil Roberts and leave Morton adrift at the bottom.
Marc McNulty scored twice as Livingston drew 2-2 with Queen of the South at Palmerston.
He scored his first when Andy Barrowman sent him clear but Michael Paton equalised with an expertly-taken free-kick.
Mark Durnan headed Queen of the South in front from a corner just before half-time but McNulty scored his second with just minutes left.
Iain Russell had a chance to kill off his former side right at the death and give Queen of the South victory but his finishing touch deserted him.