Ferrer saved four set points as he won five straight points to take the first set tie-break, clinching the lead with a crosscourt forehand smash.

After being broken to trail 6-5 in the second set, Ferrer reeled off four straight errors for his 115th-ranked opponent to even it before eventually pulling through in just under three hours.

But it wasn't without repeated scenes of frustration when he mumbled to himself and his entourage nearby.

"You say things when you're nervous in the match that you don't have a feel for. You can write a book about a match," said Ferrer about his motivation, before referring to thinner air and its effect on the ball. "The first day is not easy. You miss more, but that's all."

However, Austrian qualifier Dominic Thiem scored the biggest victory of his young career when he rallied for a 1-6 6-2 6-4 victory over Stanislas Wawrinka.

The 20-year-old Thiem showed composure beyond his years in knocking the Australian Open champion out of the clay court event to reach the third round. Thiem called on a thunderous array of baseline strokes and soft net touches to oust the third-seeded Wawrinka, who reached the final at Madrid's Magic Box tennis centre last year.

"I didn't have many matches against these top guys, so I wasn't really used to his pace. He had an unbelievable start and I didn't really know what happened," the 70th-ranked Thiem said. "I started to get used to more and more his pace and angles and his game. I played unbelievable the second and the third set."

Fabio Fognini's recent struggles on Spanish clay continued as the 13th-seeded Italian lost 7-5 4-6 6-3 to Ukraine's Alexandr Dolgopolov. Fognini failed to get out of the second round at Barcelona last month.

Nicolas Almagro will play Andy Murray next after finally dispensing with Andrey Golubev of Kazakhstan, 6-3 6-7(9) 7-6(4) with his 11th match point.

Other second round winners included Ernests Gulbis, South Africa's Kevin Anderson, Igor Sijsling and Juan Monaco of Argentina - who goes on to play defending champion Rafael Nadal on Wednesday.

Marin Cilic made light work of Joao Sousa while eighth seed Milos Raonic beat Jeremy Chardy 6-3 6-3 to book a spot in round three.