Milos Raonic lost his second round match Wednesday at the Shanghai Masters.

Unseeded Marcos Baghdatis of Cypus defeated the No. 12 seed 7-6 (4), 6-7 (5), 7-6 (3) in men's singles.

Raonic, of Thornhill, Ont., who opened the tournament by beating Marinko Matosevic of Australia 7-6 (4), 6-3, served 15 aces against Baghdatis in a match that lasted 2:40.

Roger Federer ignored recent death threats from a Chinese internet blogger and won his opening match, beating qualifier Lu Yen-Hsun of Taiwan 6-3, 7-5 in the second round.

The 17-time Grand Slam champion has had heavy security surrounding him at all times since arriving in Shanghai.

Federer saved the one break point he faced and broke serve once in each set to secure his path to the third round. He'll next face 13th-seeded Stanislas Wawrinka.

"I thought it was a good match for me," Federer said. "Obviously not having been broken is a good thing early on in a tournament.

"You hope it sets a trend for more to come."

Novak Djokovic advanced to the third round by beating Grigor Dimitrov of Bulgaria 6-3, 6-2.

The second-seeded Djokovic won the China Open in Beijing last week for his fourth title of the year and 32nd overall. He has now won 66 matches this season, the most of any player on tour.

Djokovic didn't offer Dimitrov a break-point opportunity and never lost more than one point in any service game. He also served four games at love.

"Very pleased with my serving in Beijing and obviously the first match today," Djokovic said. "So that's something that I've been working on, obviously.

"Relying on the serve in today's tennis is a big advantage. So I try to get as many free points as possible. It helped me a lot to defeat my opponent."

If Djokovic wins in Shanghai and Federer loses before the quarter-finals, the Serb would reclaim the No. 1 ranking next week.

Andy Murray received a walkover into the third round on Wednesday following the withdrawal of Florian Mayer of Germany because of a rib injury.

"I went to the gym this morning in the hotel and he was in the gym at the same time," Murray said. "I didn't know until 15, 20 minutes ago."

Murray is the two-time defending champion at the tournament with a 9-0 record after winning finals against David Ferrer last year and Federer in 2010. The third-ranked Briton also won the Olympic gold medal at the London Games and a title in Brisbane title earlier this year.

Fifth-seeded Jo-Wilfried Tsonga beat Benoit Paire 7-6 (7), 7-5 in an all-French match.

Sam Querrey of the United States came from behind to beat 14th-seeded Kei Nishikori 2-6, 6-2, 6-4 in another second-round match.

Nishikori sought a medical timeout for a right ankle injury that he sustained last week.

"It's disappointing, but I was close to a win even with this injury," Nishikori said.