Andy Murray stumbled into the last 16 of the Sony Open in Miami after overcoming a determined display from Bulgaria's Grigor Dimitrov.
The second seed was under the cosh for much of the opening set but turned things around to win 7-6 (7/3) 6-3 in one hour and 54 minutes.
Murray, who won the title here in 2009, struggled with his first serve from the off and found himself a break down in game four after some confident returning from his opponent.
The Scot broke back the very next game when Dimitrov missed an attempted lob but the Bulgarian opened up another lead straightaway, with a forehand volley at full stretch which left Murray stranded.
Dimitrov then saw two set points saved in game eight as Murray clung on by his fingertips.
However, luck was on the Briton's side in the next game when Dimitrov, serving for the set, dished up three double faults to gift Murray a route back in.
The opening set was eventually settled by a tie break, where a couple of unforced errors from Dimitrov played right into the hands of the world number two.
That knocked some of the confidence out of the Bulgarian and he dropped game two of the second set, putting a weak forehand into the net.
Murray wasted two further break points in the sixth game but soon found himself serving for the contest.
And although his first two match points went begging, it was third time lucky for Murray as Dimitrov put a backhand into the net.
Murray's next opponent will be Italian 16th seed Andreas Seppi, who also came through a tough encounter against Thomaz Bellucci 7-5 4-6 6-2.
Eighth seed Richard Gasquet eased into the last 16 with a 6-3 6-4 victory over Russia's Mikhail Youzhny while Spaniard Nicolas Almagro, the 10th seed, beat David Goffin of Belgium by the same scoreline.
In the women's event, top seed Serena Williams staged a tremendous fightback to see off Dominika Cibulkova in three sets in their fourth-round match.
The American was out of sorts on her way to losing the opening set, with 18 unforced errors, and she looked to be heading out of the tournament when she fell 3-0 behind to her Slovakian opponent in the second.
But Williams pulled out all of the stops to turn things around, with an improved serve and better returns eventually resulting in a 2-6 6-4 6-2 victory.
"Mentally I was just struggling," Williams said afterwards. "I was playing a really good opponent and I was making so many unforced errors out there - I couldn't pull myself together.
"But the crowd was great. They started saying, 'Come on Serena,' and someone over there kept telling me to relax and I listened, and I also saw my dad on the sideline and he was sitting there looking so calm and relaxed.
"I took all of that energy from the crowd and my dad and I knew I could do better."
Williams' quarter-final opponent will be fifth seed Na Li, who saw off Spanish wild card Garbine Muguruza 7-6 (8/6) 6-2.
Fourth seed Agnieszka Radwanska beat 16th seed Sloane Stephens 4-6 6-2 6-0 in one hour and 39 minutes.
Belgium's Kirsten Flipkens, seeded 30th in Miami, also advanced to the last eight with a come-from-behind 6-7 (6/8) 6-4 6-3 victory over Ajla Tomljanovic of Croatia.