Eight-time champion Rafael Nadal needed nearly two hours to overcome countryman Albert Ramos and reach the Barcelona Open Banc Sabadell third round.

While the world number one clinched his 40th successive win in Barcelona, the all-Spanish clash was far from easy.

Nadal edged a tie-break in the first set and broke Ramos in the second to secure a 7-6 (7/2) 6-4 victory, setting up a tie with Ivan Dodig. To come through at all was of huge relief to Nadal, who was a surprise loser in Monte Carlo last week.

"It was a positive victory for me," said Nadal on the ATP's official website.

"Obviously I didn't play my best match, but after the defeat in Monte-Carlo, the next match on court was never going to be easy. I am happy with the way I fought and proud of the victory today. The victories are more important when you haven't played well. I feel happy to be through on a tough day for the top seeds."

Croatian Dodig progressed after beating 13th-seed Feliciano Lopez in a day of shocks, which also saw fellow seeds Fabio Fognini, Jerzy Janowicz and Alexandr Dolgopolov exit to Santiago Giraldo, Jurgen Melzer and Albert Montanes respectively.

The biggest surprise, though, was that second-seed David Ferrer lost 6-4 6-2 to Russia's Teymuraz Gabashvili - the world number 55 - just a week after stunning Nadal in Monte Carlo.

Other winners on Wednesday were the 11th-ranked Fernando Verdasco against Kenny De Schepper, the 12-seeded Marin Cilic over Andrey Kuznetsov and the sixth-rated Nicolas Almagro against Martin Klizan.