The end of Roger Federer's long reign as world No1 moved closer when he suffered a shock second-round defeat by Frenchman Gilles Simon at the Toronto Masters on Wednesday night.

Back on court for the first time since his epic loss to Rafael Nadal in the Wimbledon final, Federer was beaten 2-6 7-5 6-4, with his ranking now under serious threat from Nadal who beat American qualifier Jesse Levine 6-4 6-2.

Federer had looked ready to take out his Wimbledon disappointment on Simon when he won the first four games on the way to the opening set.

But Simon, riding the momentum from his championship win in Indianapolis on Sunday, refused to buckle, battling back to beat the 12-times grand slam winner and reach the third round.

It was the first time Federer had lost his opening match in a tournament since falling to Briton Andy Murray in Dubai in March.

"The hard court season just started so it is not the end of the world, but I wish I could have started better," said Federer. "I like this surface, I like this tournament, I have done well in the past here so it definitely hurts.

"I have to regroup and look forward. The bigger picture is the Olympic Games and the US Open and those are the places I really want to win, so I have to make sure I am ready for that," he said.

The 22nd-ranked Simon represented a tricky opponent for the rusty Swiss master who had only resumed practice four days before arriving in Toronto.

Simon is well into his hardcourt campaign after claiming last week's title in Indianapolis, and said: "I was playing like I was in a dream. I just saw the ball and hit it as hard as possible.

"It is really unbelievable to beat Roger like this. For sure this is my best victory."