The 31-year-old mainlander - who is playing in her first tournament since suffering an ankle injury in January's Australian Open final - will face world No 1 Serena Williams in the last eight.

Williams struggled too, having to come from a set down to win 2-6, 6-4, 6-2 against Slovakia's 13th seed Dominika Cibulkova.

Li - the 2011 French Open champion and two-time Australian Open finalist - made 39 unforced errors, including four double faults, and allowed her 19-year-old opponent to battle back to 5-5 in the first set from 5-1.

Even at 6-1 in the tiebreaker Li faltered as 73rd-ranked Muguruza, who had claimed the scalps of the seeded Caroline Wozniacki and Anastasia Pavlyuchenkova in previous rounds, fought back to 6/6.

However, fifth-seeded Li pulled herself together to take the next two points and the set.

Li was more clinical in the second set breaking Muguruza, who was born in Venezuela but has a Spanish father who now lives in Barcelona, in the second game and then again when closing out the tie as her opponent served a double fault on match point.

Williams, who is bidding for a record sixth Miami title, admitted she had not been at her best and at 4-1 down to Cibulkova in the second set and staring defeat in the face she had had to pull herself together.

"I was struggling mentally, I was making so many errors," said Williams, who regained the top spot in Doha last month but has not played since.

"I could not pull myself together. Someone [a fan] kept telling me to relax and I listened to him. I saw my dad courtside and he was so calm, it helped me."

Murray would have faced a tougher task had not the 21-year-old lost his composure when serving for the first set at 5-3. He double faulted three times to allow Murray to break back and the Scot duly got the better in the tie-break.

It is the second time in as many tournaments that Dimitrov has cracked when serving for a set against a top-ranked player, serving up four double faults when he led world No 1 Novak Djokovic 5-3 in the third round at Indian Wells.