The top seed was already in trouble at a set and a break down to unseeded McDonald when he crouched down in obvious pain clutching his left hip after chasing out wide for a forehand.
Nadal called for the trainer after limping through the rest of the game and headed off court for treatment.
A retirement seemed on the cards, with the Spaniard’s wife Maria crying in the stands, but he opted to continue despite limping around the court.
Nadal managed to hold his serve until the 11th game, roared on by fans still believing he could somehow turn things around, but it was a case of when not if McDonald would find a way through and he finished off a 6-4 6-4 7-5 victory.
It was a hugely sad way for Nadal to exit the tournament a year after his near miraculous run to the title when he feared his career may have been over because of a chronic foot problem, and there must be serious doubt over whether he will play again at Melbourne Park.
He went on to win a 22nd grand slam title at the French Open but has found the going tough since suffering an abdominal tear and pulling out of Wimbledon ahead of the semi-finals.
Nadal went into a first-round clash with Britain’s Jack Draper having lost six of his previous seven matches and, although he scrapped to a four-set victory, he was some way below his best level.
The same was true in the early stages against McDonald, a 27-year-old ranked 65 looking for his first victory over a top-five player at a grand slam.
The match was played under the roof on Rod Laver Arena on a wet day in Melbourne, and the indoor conditions certainly suited the flat-hitting McDonald.
He caught Nadal cold and broke the Spaniard twice to lead 4-1 before the top seed dug in and made a fight of the opening set.
Nadal, who complained before the tournament about the balls, produced a couple of trademark forehands but there were also too many errors, and more often than not it was he who broke down first in baseline rallies.
Nadal created one break point with McDonald serving for the set only to hit the roof with a mis-hit, and he did not get another opportunity.
McDonald, who battled past his compatriot Brandon Nakashima in five sets in the first round, broke serve again at the start of the second.
Nadal looked like he might have turned things around when he reeled off three games in a row but McDonald broke through again in the seventh game, and it was moments late when injury struck.