The opening two sets were evenly contested, with neither player able to open up a substantial advantage.
As a result, both headed into tie-breaks, with Murray winning the pair. The Brit took control of the first one early on and eventually ran out a 7-5 victor.
Lopez gained the initiative in second breaker with a mini-break to go 4-1 in front. However, Murray responded by winning six of the next seven points available to take a two-set lead.
The Scot looked to be heading for a three-set victory when a double fault from world number 31 Lopez handed him a 4-2 lead in the third set.
Lopez pegged Murray back during his next two service games though, while also holding his own on both occasions to win 6-4 and force the match into a fourth set.
The complaint appeared to be hampering the 25-year-old throughout the next set, although it didn't prevent him from holding all of his service games, despite facing numerous break points.
Lopez mimicked Murray's performance by also holding his six games with the ball in hand, meaning that a third tie-break was reached.
A powerful backhand stroke put Murray in command of the breaker at 6-4, before a misjudged drop shot by Lopez hit the net to give Murray a place in the final 16.