Sharapova, who returned to tennis last April following a 15-month doping ban, continued to struggle to find form this season as she dug herself into an early hole and never fully recovered.
Stosur, the 2011 US Open champion, needed more than two hours to overcome American Lauren Davis 3-6, 6-3, 6-3.
The win offers the former world No.4 Stosur the chance to re-enter the top 40, where she has only spent one week since August.
Sharapova's shot choice often backfired as she failed to take advantage of the momentum and was unable to pounce on second serve returns, most notably at 4-4 30-30, and Osaka was back rolling once more as the Russian lost her footing.
"I knew (Sharapova) would fight for everything because I've watched her since I was little", Osaka told WTA.com following the match.
Bencic survived a huge test against Timea Babos, edging through 1-6, 6-1, 7-6 (7-4).
Serena Williams returns to the tour for the first time in 14 months Thursday when she plays a first-round match.
"He shows there is no limit", said third-seeded Grigor Dimitrov on Wednesday.
Federer opens the defence of his Indian Wells title by playing a second-round match against either American Ryan Harrison or Federico Delbonis of Argentina.
Amanda Anisimova, 16, of New Jersey, the junior U.S. Open champion and a wild card entry here, won her first WTA main draw match, a 6-2, 6-2 victory over Pauline Parmentier of France. Federer comes into the elite event as the oldest ATP Number One in history.
World No. 44 Osaka, ranked three places below Sharapova and 10 years her junior, said she was ready for a tough battle against the five-time Grand Slam victor. This was Sharapova's first opening-round loss in Indian Wells and the first time since 2003 when Sharapova had a three-match losing streak. Both players are in opposite halves of the draw so they would not meet each other until the final.