The world number three was a long way from his best in seeing off the Lithuanian qualifier but managed to progress 6-3 6-4 7-5 to set up a meeting with the winner of the all-French clash between Gilles Simon and Gael Monfils.
Murray is familiar with Berankis' game but that did not prevent him from encountering some unexpected problems.
He said: "We practise a lot together, he hits the ball very flat and these courts were playing quick today.
"I was struggling. He was making me feel pretty uncomfortable on the court with his style. I need to strike the ball better.
"My timing was off and I was leaving a lot of balls very short and allowing him to dictate some of the points. But hopefully it'll get better in the next round."
Murray will have been further boosted by the other results in his quarter, with Juan Martin Del Potro and Marin Cilic both going out.
Two breaks put Murray in control of the first set and although Berankis got one back he was unable to prevent the Scot from taking it.
Murray was playing well within himself and Berankis was starting to dominate.
The 22-year-old broke for a 4-2 lead only to hand the initiative straight back to the Olympic champion with a sloppy game.
Murray threatened again at 4-4 and with Berankis wobbling, he broke at the fourth opportunity before establishing a two-set lead.
The third seed was finally starting to look like one of the title contenders and he kept his foot on the gas by breaking for 2-1 in the third.
But serving for the match, Murray again had problems as at 15-40 he dumped a weak forehand into the net.
If there was one positive to come out of today for the Scot it was his ability to respond well to adversity and he showed his fighting spirit to break back straight away.
And there was no mistake at 6-5 as he got the job done to move into the second week.
Elsewhere, sixth seed Del Potro lost to Frenchman Jeremy Chardy after hitting back from two sets down. Chardy held his nerve to come through 6-3 6-3 6-7 (3/7) 3-6 6-3.
Cilic, seeded 12, went down, also in five, to Italy's Andreas Seppi.
On a good day for France, Richard Gasquet and Jo-Wilfried Tsonga also progressed.
Ninth-seeded Gasquet beat Ivan Dodig 4-6 6-3 7-6 (7/2) 6-0 while seventh-seeded Tsonga cruised past Blaz Kavkic for the loss of seven games.