MADRID (AP) Roger Federer came close to another upset before finally beating Feliciano Lopez in three gripping sets at the Madrid Open, and rivals Rafael Nadal and Novak Djokovic continued their winning streaks with ease.

Federer, beaten by Jurgen Melzer in Monte Carlo last month, saved a match point in a marathon 7-6 (13), 6-7 (1), 7-6 (7) win after three hours.

Djokovic ran his winning streak to 30 by beating Kevin Anderson of South Africa 6-3, 6-4. Nadal is unbeaten in 35 matches on clay after his 6-1, 6-3 rout of Marcos Baghdatis.

The top-ranked Nadal next plays 2009 U.S. Open champion Juan Martin del Potro, who swept aside Marin Cilic 6-3, 6-0 in 64 minutes.

``I think he's the worst rival to have to face in the second outing of a tournament,'' Nadal said.

Del Potro, who has dropped down the rankings following a serious wrist injury, wasn't looking forward to playing the five-time French Open champion on clay either.

``He's at home, playing really very well and hasn't lost on this surface for around two years,'' Del Potro said.

The No. 3-ranked Federer next meets Xavier Malisse of Belgium after overcoming Lopez in front of a fiercely partisan home crowd at the Caja Magica in Madrid.

Lopez was left to rue squandering a 5-2 lead in the deciding third-set tiebreak.

Real Madrid star Cristiano Ronaldo was in the crowd to watch Wednesday's action and was treated to superb displays from the world's top two players.

Nadal broke Baghdatis's serve three times in the first set and once in the second, pinning the Cypriot to the baseline with accurate first serves and precise passing shots.

``It was more or less a comfortable match for me against an always complicated rival, who last time we met beat me,'' said Nadal who lost to the Cypriot at Cincinnati in August.

Djokovic's winning streak dates back to Serbia's win in the Davis Cup final last December. This year, he's started 28-0, the best beginning to a season since Ivan Lendl went 29-0 in 1989.

In the next round, Djokovic will play Guillermo Garcia-Lopez of Spain, who has yet to beat the Serb in four meetings.

It's a fact that I am playing the best tennis of my life and I'm definitely happy about it,'' said Djokovic, who attributed his good form to astrong mental ability to handle the pressure and play the right shots at the right time.''

Seventh-seeded Tomas Berdych and fifth-seeded Robin Soderling were also winners.

On the women's side, Petra Kvitova of the Czech Republic eased past second-seeded Vera Zvonareva 6-1, 6-4 to reach the quarterfinals.