"After yesterday's scan, the doctor has recommended I don't risk further injury," Sharapova, who was awarded a wildcard to compete this week in California, said in a statement on the tournament's website.
"Monday night’s crowd was so special and I wish I could continue playing but I have to make a preventative decision.”
Sharapova, playing her first match in the United States since 2015, was made to work against world number 80 Brady, needing two hours to secure the 6-1 4-6 6-0 win.
News that makes sense
Your trusted source for staying up-to-date with the world around you. Get free daily news updates and analysis, straight to your inbox.
Her early exit means Ukrainian seventh seed Lesia Tsurenko advances to the third round by walkover.
It marks the second time in three months that the five-times grand slam champion's comeback has been interrupted by injury as she also retired from her second round match at the Italian Open in mid-May after injuring her left thigh.
Sharapova, banned after testing positive for heart drug meldonium at the 2016 Australian Open, has had mixed results since re-joining the WTA Tour.
The 30-year-old Russian reached the semi-finals as a wildcard in Stuttgart but fell in the second round at Madrid to Canada's Eugenie Bouchard who days earlier had labelled the Russian a "cheater."
(Reporting by Frank Pingue in Toronto; Editing by Robin Pomeroy/Steve Keating)
