The 2011 US Open champion dropped the first set and was broken four times during her 3-6 6-3 6-3 victory on Thursday over Lauren Davis.
The former world No 1, and twice a victor in the California desert, Sharapova was one of the tournament's leading names after missing the last two events.
Sharapova reached the semi-finals of the Shenzhen Open in January and round three of the year's first Grand Slam, the Australian Open, but lost in the opening round in Doha last month.
Stosur also avoided adding to the group of five top-50 players losing in the first round including Croatian Donna Vekic who fell to Greece's Maria Sakkari. Yuki now leads head-to-head record 3-1 against the 22-year-old Ramkumar.
Eggs stored at a fertility clinic in danger due to a malfunction
This story has been corrected to show that around 700 patients are affected, not 500 patients. The hospital said it does not yet know what caused the problem and is investigating.
Sharapova won the title in 2006 and 2013, but her bid for a third came to an end at the first hurdle.
She trailed 4-1 in the first set before holding serve at 4-all.
By the second set, Osaka again gained an early lead as breaks went back and forth. Osaka held serve for 5-4 and broke Sharapova on a double fault to close out the set. The 16-year-old Anisimova, who earned a wild card into the main draw, is the U.S. Open junior champion.
In a marathon battle spanning two hours and 23 minutes, Switzerland's Belinda Bencic knocked out Timea Babos 1-6, 6-1, 7-6 to set up a second-round clash with Jelena Ostapenko while Sachia Vickery beat Canada's Eugenie Bouchard 6-3, 6-4. She returned to tennis only last April.