SHANGHAI, China - Canadian Milos Raonic lost to David Ferrer for the third time this season, going down 7-5, 7-6 (7) to the third seed from Spain in the second round of the Shanghai Masters on Wednesday.

Raonic was beaten by Ferrer at the Australian Open and in Monte Carlo three months later. The Spaniard is ranked fifth in the world, compared to No. 31 for the Canadian.

"I had my opportunities and came up short in both of the sets," Raonic said. "I didn't take care of my serve. David makes you play all the points, I wasn't able to close it out today."

The 20-year-old from Thornhill, Ont., is returning from July hip surgery after a fall at Wimbledon.

Raonic lost a week ago to Rafael Nadal in the second round in Tokyo.

In other action, Rafael Nadal and Andy Murray advanced to the third round, although only the Spaniard had to step onto the court.

Raonic went up an early break in both sets but failed to capitalize on the opportunities against the gritty Spaniard who has built his top-10 career on grinding baseline tennis made comebacks.

Ferrer broke just in time in the opening set and then served out for the lead. In the second, he went down early and bounced straight back. Raonic had a set point in the tiebreaker but was eliminated as Ferrer advanced into the third round on his second match point.

"It's a good thing in general to know I had the chances," said Raonic, adding his European playing schedule will be full for the remaining four weeks of the ATP season.

"I want to improve and get in as many matches as possible."

The Canadian matched the 11 aces he fired in his Tuesday victory over France's Michael Llodra and lost serve three times as he works to find his competitive rhythm after more than three months out.

The top-seeded Nadal easily beat countryman Guillermo Garcia-Lopez 6-3, 6-2, while Murray received a walkover when his opponent, Dmitry Tursunov of Russia, pulled out with a wrist injury before their match.

Murray, the second seed and defending champion, hasn't played a match yet in Shanghai. He received a bye in the first round.

Earlier Wednesday, fourth-seeded Jo-Wilfried Tsonga was knocked out by Japan's Kei Nishikori 6-7 (1), 6-4, 6-4. The Frenchman fought off two match points with aces before hitting a backhand long to hand Nishikori the win.

The loss will hurt Tsonga's chances of claiming one of the four remaining spots in the season-ending ATP World Tour Finals in London. He currently sits in eighth position in the standings, the last qualifying spot.

Sixth-seeded Tomas Berdych, fresh off a win last week at the China Open in Beijing, also advanced with a 6-4, 6-3 win over fellow Czech Radek Stepanek.

Garcia-Lopez won their last meeting at the semifinals of the Thailand Open in 2010, Nadal's first tournament after capturing the U.S. Open.

After losing the first set and dropping his serve to start the second set Wednesday, Garcia-Lopez tried mixing up his game by hitting drop shots to bring Nadal into the net.

He broke Nadal's serve to level the score at 2-2, but Nadal immediately broke back with a sensational defensive point in which he got to a drop shot, chased down a lob and then hit a stab backhand volley for a winner.

Nadal plays 15th-seeded Florian Mayer of Germany in the third round, while Murray faces Stanislas Wawrinka, the 13th seed from Switzerland.

Murray's draw has opened up with the losses of Tsonga and fifth-seeded Mardy Fish, who fell to Australian Bernard Tomic on Tuesday. The highest seed remaining in his half of the draw is No. 8 Gilles Simon of France.

Tsonga appeared sluggish early in his match, spraying forehands long and allowing Nishikori to run him around the court. Although he won the first-set tiebreaker, he was broken twice and hit only four winners to drop the second set.

The 47th-ranked Nishikori, who was 1-9 against top 10-ranked players before the match, then broke Tsonga twice more in the third set to close out the match after nearly two and a half hours.

"He's really talented, especially when everything works," Tsonga said. "Today he didn't miss one drop shot. He played really well. He returned unbelievable. I think nobody breaks me many times like this."

American teenager Ryan Harrison, who upset 11th-seeded Viktor Troicki in the first round, lost to fellow qualifier Matthew Ebden of Australia, 6-4, 6-2. Ebden, ranked 124th, had only won eight matches on the ATP tour coming into Shanghai.

Spain's Juan Carlos Ferrero rallied from a set down to beat compatriot and 16th-seeded Fernando Verdasco 4-6, 6-3, 6-2.

In other second-round matches, Colombia's Santiago Giraldo edged out 14th-seeded Jurgen Melzer of Austria, 4-6, 6-4, 7-6 (5), and Alexandr Dolgopolov, the 12th seed from Ukraine, defeated qualifier Albert Ramos of Spain, 5-7, 6-3, 6-2.

With files from The Associated Press