Trailing 6-3, 2-0, the Canadian slipped chasing down a Barty shot and turned her ankle. After losing the game, the Canadian called for the trainer and after receiving treatment, attempted to resume, but she couldn't go on after one more game.
The victory for the Australian marks the first time a player has won consecutive Miami titles since Serena Williams was victorious three years in a row from 2013 to 2015.
Barty again the champion after Andreescu retires with ankle injury
After an easy hold to open the match, Barty held 15-40 on Andreescu's first service game, but after the Canadian saved the first with an ace, the Aussie fired off a forehand winner to go in front 2-0 and another hold made it 3-0.
Andreescu clawed her way back after breaking the Barty serve, but after a slice of luck on a forehand gave the world number one a break point, she converted after ripping a crosscourt backhand winner to claim a 4-2 advantage.
Serving for the set at 5-3, a jamming serve brought up set point for Barty and she clinched the set after more aggressive play from the Aussie drew an error from Andreescu.
The eighth seed faced break point immediately in the second set and an untimely double fault gave Barty the edge. At 2-0, 15-0 was when the fateful moment came as Andreescu slipped, played out the game, got broken, called the trainer, played one more game and retired.