Williams, 36, was playing in her first Grand Slam since the birth of her daughter in September a year ago.
Maternity leave means Williams, the 23-time Grand Slam victor, is now ranked 451 in the world, but this arm injury will only see her fall further down if she can't recover swiftly.
"I unfortunately been having some issues with my pec muscle", she explained. The 36-year-old was playing in her first Grand Slam since returning to the sport following the birth of her daughter last year.
"I'm beyond disappointed. I gave up so much and gave everything on the court, all for this moment", Williams told a hastily-arranged news conference. I always try to think positive'.
Halep had earlier thumped Elise Mertens and said of facing the German: 'Well, it's every time it's a tough match, and every time I expect the same.
Williams added: "The first time I felt it was against [Julia] Goerges in my last match".
However, the 23-time Grand Slam victor will now have to focus on making a recovery in time for the start of the grass-court season.
"It's been a while, and I think a lot has happened in our lives for the both of us in very different ways". She said it is the first time she has had to withdraw from a major tournament because of an injury.
Sharapova turned the situation around, but Garcia got a lot of praise.
Williams admitted it was painful to walk away from a first match against Sharapova since the 2016 Australia Open, after which the Russian was given a 15-month doping ban. I didn't manage to find the rhythm, to be focused on my match.
However, she added that, at the same time 'I made a promise to myself and to my coach and my team that if I am not at least 60 percent or 50 percent, then I probably should not play.
"I'm having an MRI (scan) tomorrow, I'm going to stay here to see the doctors and see as many specialists as I can", she said. "Her game matches up so well against mine". "Physically I'm doing great", she said.
Sharapova advances to an all-former-No.
If you were hoping to get your fix of Serena Williams battling Maria Sharapova, you're going to have to wait.