Andy Murray made a winning return to clay after battling past Nicolas Almagro 6-1 1-6 6-4 to reach the third round of the Madrid Open.
The Scot, who had a first-round bye, cruised through the opening set but then went onto lose six games in a row after breaking the Almagro serve in the first game of the second.
Serve was dominant in the third until a backhand error from the world No 24 gifted Murray the vital break on match point in one hour and 46 minutes to set up a meeting with Colombian Santiago Giraldo next.
Murray's last appearance at an ATP Tour event on clay was in Rome last May and his previous clay Tour event victory came against Gilles Simon at last year's Open in the Spanish capital.
The British no 1, who is still searching for a coach to replace Ivan Lendl, told Sky Sports: "It was a tough match. He was just going for bombs on every shot. He was serving huge and ripping the ball from the back of the court.
"I got a bit tentative when he broke me back at the beginning of the second set. If I had got ahead and got the hold, I would have been ok, but wasn't to be but hung on at the end."
"It's obviously a surface I have struggled with the last couple of years physically, so I just need to make sure I stay on top of my recovery and warm up properly all the time."
The quicker surface at the Caja Magica seemed to help a revitalised Murray who made the perfect start by breaking Almagro twice as he moved comfortably into a 5-0 lead.
Almagro - conqueror of Rafael Nadal in Barcelona last month - looked a little worse for wear after needing 11 match points to see off Kazakh qualifier Andrey Golubev in the previous round.
The 28-year-old took an injury time out due to a left foot problem before the start of the sixth game - which he eventually held - but it was the Scot who easily sealed the set on his next service game.
An athletic Murray, who was playing his first match in a month, was moving well across the dirt and showcasing a fine array of shot selection which had Almagro chasing shadows at times.
However, after Murray broke in the opening game of the second set, the two-time Grand Slam champion then suffered a major wobble.
In a remarkable turnaround in fortunes former top 10 player Almagro conjured the mental resolve to win the next six games in a row to take the contest into a decider.
Murray regained his composure and consistency to stand firm against the power of the Spaniard.
At 5-4 on Almagro's serve, the seventh seed opened up match point and he duly sealed the deal when a wild backhand landed in the tramlines.
It was Murray's first win against a Spanish opponent on the surface since he defeated Tommy Robredo five years ago at the same venue.