MADRID (AP) -- Defending champion Novak Djokovic recovered from a 3-0 deficit in the third set to defeat Nicolas Almagro 6-1, 4-6, 7-5 and reach the third round at the Madrid Open on Wednesday.
Djokovic rallied in the final set by breaking Almagro to go up 6-5 and served out to earn his 15th win of the season in over two hours.
The second-seeded Djokovic will next play either Gilles Simon of France or Feliciano Lopez of Spain.
Djokovic cruised in the first set by breaking the 76th-ranked Almagro three times. The Spanish wild card entrant rallied in front of the home crowd in the second set, saving all four break points he conceded and breaking at 4-5 to eventually extend the match.
Almagro was two points away from going up 4-2 in the final set but was not able to capitalize on his chances.
It was an important opening-round win for the second-ranked Djokovic as he tries to turn his season around and regain his form going into the French Open later this month.
He won in Doha to start the season but never made it past the quarterfinals in the following four tournaments he played. In his first clay-court tournament, in Monte Carlo, Djokovic was eliminated by David Goffin in quarterfinals.
Djokovic had his playing time diminished this year because of an elbow injury. Wednesday's match was his first since splitting with longtime coach Marian Vajda.
Nick Kyrgios of Australia defeated Ryan Harrison of the United States 6-3, 6-3 to set up a third-round match against either four-time champion Rafael Nadal or Fabio Fognini of Italy, who will play later on Wednesday.
Fifth-seeded Milos Raonic of Canada defeated Gilles Muller of Luxemburg 6-4, 6-4, while sixth-seeded Kei Nishikori of Japan recovered from a slow start to beat Diego Schwartzman of Argentina 1-6, 6-0, 6-4.
Nishikori, a finalist in Madrid in 2014, is playing in his first tournament since March. He withdrew from Barcelona last month because of a right wrist injury.
"In the beginning I wasn't playing 100 percent," Nishikori said. "But in the second and third (sets) I was feeling pretty good on the court, moving well, so I was very happy."
Nishikori will play in the third round against Spaniard David Ferrer, who advanced after 10th-seeded Jo-Wilfried Tsonga of France withdrew before the match because of a shoulder injury.
Tomas Berdych of the Czech Republic defeated Robin Haase of the Netherlands 7-6 (5), 6-3,
In the women's draw, eighth-seeded Svetlana Kuznetsova of Russia defeated Qiang Wang of China 6-4, 7-5.