Williams, 37, who came in second place in the Wimbledon final last month, complained of back spasms and pulled out of the tournament in Toronto.
The 23-time grand slam champion became emotional and cried.
After learning that she had won the championship due to Williams’ pullout, Canadian player Bianca Andreescu, 19, walked over to the tennis champion to comfort her.
The American was a break down at 1-3 in the first set when she withdrew.
"I'm sorry I couldn't do it today, I tried," said the 23-time Grand Slam champion. "It's been a tough year, but we'll keep going."
Andreescu, who won her first WTA title at Indian Wells earlier this year, becomes the first Canadian to win the Rogers Cup women's singles title since 1969.
"Serena, you made me cry. I know how it is to pull out of tournaments, it's not easy," she said.
"This wasn't the way I expected to win. You are truly a champion. I've watched you win so many times, you are truly a champion on and off the court.
"I'm speechless right now. This has been a dream come true."
Williams' only previous retirement in a singles final came at the Rogers Cup in 2000 - the year Andreescu was born.
Williams was seeking to win her first title since returning to competition in 2018 after the birth of her daughter.
The US Open, where Williams will hope to win her 24th Grand Slam title, starts on 26 August.
She reached the Wimbledon final last month - losing to Simona Halep - but struggled with a knee injury earlier in the year.