Germany's Alexander Zverev became just the third man to beat Roger Federer this year as the 20-year-old German won his fifth title of 2017 in Montreal.
Zverev, ranked eighth, won 6-3 6-4 at the Rogers Cup to claim his second Masters 1000 title and extend his winning run to 10 matches.
Federer, 36, lost for just the third time in 38 matches this year.
The Swiss can still take the number one ranking if results go his way at the Cincinnati Open this week.
Either Federer or Rafael Nadal will replace Andy Murray at the top of the standings on 21 August.
Zverev gave further evidence that he is a contender for the biggest titles as he became only the second active player after Jo-Wilfried Tsonga to win two Masters titles, outside the 'Big Four' of Federer, Nadal, Novak Djokovic and Murray.
The German has drawn level with Federer on a Tour-leading five titles in 2017, following up last week's victory in Washington.
Federer to make Cincinnati decision
Federer, who missed the clay court season, was playing in his first tournament since winning Wimbledon on 16 July.
"After vacation and practice, it's always a bit of a shock for the body," he said. "I felt all right all week. Had a bit of muscle pain, aches and pains here and there, just because it's back on the match courts, on the hard courts."
He said he will "take a decision in the next couple of days" whether he plays in Cincinnati, where he has a first-round bye.
The US Open, the final Grand Slam of the year, begins on 28 August.
Federer added: "Looking ahead to the US Open, obviously I want to be in the best possible shape. Winning my third of the year, my 20th Grand Slam, would be completely insane. I just hope I'm going to be 100% ready when the moment arises."
Japan's Kei Nishikori has become the latest top 10 player to pull out of Cincinnati, after the world number nine withdrew with a wrist injury.
Murray and Wimbledon finalist Marin Cilic have withdrawn, while 2016 US Open winner Stan Wawrinka and 12-time Grand Slam champion Djokovic will miss the rest of the season.
Former world number ones Maria Sharapova and Victoria Azarenka have withdrawn from the women's event.