The world number two was struggling with a hip problem, but appeared to be getting back on terms in the second-round match having won the second set to level the match at 3-6 7-6(5).
But immediately afterwards, Murray shook his Spanish opponent's hand and retired, raising concerns over his fitness ahead of the French Open, which begins on May 26.
"I pulled out because there is a good chance I wouldn't be playing tomorrow. We'll have to wait for Paris. I'd be very surprised if I were playing in Paris," said Murray, who endured a miserable 26th birthday.
"I need to make a plan as to what I do. I'll chat with the guys tonight and make a plan for the next few days then make a decision on Paris after the next five days.
"I want to make sure it goes away. It's been a problem since the end of 2011 but it got bad during last year's clay season."
The Scot was ill at ease throughout, slipping a set and 4-1 down in double-quick time. He called the trainer to look at the hip problem, and appeared to be in discomfort between points.
Murray, who dug himself out of some perilous positions on his run to the quarter-finals of the Madrid Masters, recovered the two breaks of serve to level at 4-4, only to throw it away and allow Granollers a chance to serve out the match at 5-4. Again, summoning some of his best tennis when he needed it, Murray broke back.
He spurned a set point at 6-5 up, before the set went to a tie-break. Having won it, though, the crowd were shocked to see there would be no decider.
The only previous occasion when Murray has been forced to retire mid-match came at the 2007 Hamburg Masters when he snapped a tendon in his wrist.
Rome Masters results
5-Rafa Nadal (Spain) beat Fabio Fognini (Italy) 6-1 6-3
Ernests Gulbis (Latvia) beat Viktor Troicki (Serbia) 6-1 6-1
4-David Ferrer (Spain) beat Fernando Verdasco (Spain) 5-7 7-5 6-3
Philipp Kohlschreiber (Germany) beat Albert Ramos (Spain) 6-4 6-1
Jeremy Chardy (France) beat 16-Kei Nishikori (Japan) 6-4 6-1
Marcel Granollers (Spain) beat 3-Andy Murray (Britain) 6-3 6-7(5) 0-0 (A. Murray retired)
Benoit Paire (France) beat Julien Benneteau (France) 6-7(3) 6-4 7-6(4)
Gilles Simon (France) beat Mikhail Youzhny (Russia) 7-5 6-3
Alexandr Dolgopolov (Ukraine) beat 15-Stanislas Wawrinka (Switzerland) WO
Jerzy Janowicz (Poland) beat 8-Jo-Wilfried Tsonga (France) 6-4 7-6(5)
- Sports & Recreation