The 36-year-old said she had suffered a pectoral muscle injury in her third-round win over Julia Goerges and “can’t serve at all”.
The 23-time Grand Slam champion added that she would stay in Paris for scans on the injury to find out how long she will be out of action.
“I unfortunately have been having some issues with my pec, my pec muscle, and (it) has unfortunately been getting worse to the point where right now I can’t actually serve. It’s kind of hard to play when I can’t physically serve,” she explained.
She was unable to say whether or not she would be fit for Wimbledon which gets underway in four weeks’ time.
“I’m beyond disappointed,” added three-time Roland Garros champion Williams who was playing in her first Grand Slam since winning the 2017 Australian Open while two months pregnant.
She was also in just her third tournament of the year after giving birth to daughter Olympia in September.
“I gave up so much time with my daughter and time with my family all for this moment. So it’s really difficult to be in this situation.”
The shock withdrawal came just minutes before she was due on Court Philippe Chatrier to face fierce rival Sharapova.
Williams has not lost to the Russian since 2004, winning the last 18 matches.
It had been the most eagerly-awaited match of the tournament, coming just two days after Williams had blasted Sharapova’s autobiography for being “100 percent hearsay” when it came to references about her.
Sharapova, the champion in Paris in 2012 and 2014, goes on to play a first quarter-final at the Slams since losing to Williams at the same stage at the 2016 Australian Open.
It was in Melbourne that Sharapova tested positive for meldonium after which she served a 15-month doping ban.
The Russian will face either 2016 champion Garbine Muguruza or Lesia Tsurenko of Ukraine for a semi-final place.
“I was looking forward to my match against Serena and am disappointed that she had to withdraw,” said Sharapova in a statement.
“I wish her a speedy recovery and hope she returns to the tour soon.”
Monday’s bombshell announcement was the first time in her 20-year career that Williams had pulled out during a Grand Slam event.
Despite her well-documented fall-outs with Sharapova, Williams insisted she had been looking forward to the match.
“I love playing Maria — it’s just a match I always get up for. Her game matches so well against mine.”
Despite playing just four matches in 2018 before Roland Garros, Williams played doubles in Paris with sister Venus.
They had been knocked out on Sunday by Andreja Klepac and Maria Jose Martinez Sanchez with the American sisters getting a 6-0 bagel in the final set.
Serena had gone into that match wearing her striking all-black catsuit but she admitted she had had to tape her serving arm to try and protect the injury.
“Every match has been getting better for me. Physically I’m doing great.
“I sacrificed so much to be at this event. I can only take solace in the fact I’m going to continue to get better.
“And I had such a wonderful performance in my first Grand Slam back. I just feel like it’s only going to do better.”
However, her status for Wimbledon where she has been champion seven times, will only become clear once she has had an MRI.
“I made a promise that if I’m not at least 60 percent or 50 percent, then I probably shouldn’t play,” she added.
“The fact that I physically can’t serve at all is a good indication that maybe I should just go back to the drawing board and stay positive and try to get better and not get it to a point where it could be a lot worse.”