Williams, 37, was a break down at 1-3 in the first set when she withdrew and 19-year-old Andreescu comforted her courtside.
"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. 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,” Andreescu said.
Williams' only previous retirement in a singles final came at the Rogers Cup in 2000 - the year Andreescu was born.
The legendary tennis player still hopes to win her 24th Grand Slam title at the US Open, which starts on 26 August. She also reached the Wimbledon final last month - losing to Simona Halep - but struggled with a knee injury earlier in the year.