TORONTO (AP) Top-ranked Novak Djokovic survived a scare to beat Gilles Muller 7-5, 7-6 (3) on Wednesday in the Rogers Cup, his final event before the Rio Olympics.

''I actually think that Toronto is a great way for me to prepare for the Olympic Games and what's coming up after that,'' Djokovic said. ''But also, you know, I enjoy my time in this tournament that I always love playing.''

The Serbian star noted that he had extra time off after falling in the third round at Wimbledon. The Rogers Cup rotates between Toronto and Montreal, with the women playing in Montreal this week.

''I enjoy Canada, both cities, Toronto and Montreal, and the past results in history show that I have a good time on Canadian soil, so I try to get the best out of it,'' said Djokovic, the tournament winner in 2007, 2011 and 2012.

Djokovic struggled against Muller in his first hard-court match since March, both with his serves and his short game. Ultimately, unforced errors were Muller's undoing, with both sets easily in reach of the unseeded player from Luxembourg.

''Gilles Muller is a very difficult player to play against in quick conditions,'' Djokovic said. ''He takes away the time of the opponent. He serves and volleys second serve a lot, as well, which he's one of the rare guys that does that. He likes to play quick, and I think the warm day like today played a lot in his favor.''

Djokovic will face qualifier Radek Stepanek of the Czech Republic in the third round.

Third-seeded Kei Nishikori of Japan downed American Dennis Novikov 6-4, 7-5; and fourth-seeded Milos Raonic of Canada beat Taiwan's Lu Yen-hsun 6-3, 6-3.

American qualifier Ryan Harrison outlasted ninth-seeded countryman John Isner 7-6 (3), 6-7 (4), 6-4, and 10th-seeded Gael Monfils of France topped Canada's Vasek Pospisil, Canada, 7-6 (6), 6-0. Monfils won the Citi Open on Sunday in Washington.