Sixth-seeded Stosur lost a see-sawing third round encounter with Russian Nadia Petrova [ Images ] 6-1, 6-7, 7-6 at the Indian Wells Tennis Garden, before Sharapova finally wrapped up a 6-3, 6-4 win against Romania's Simona Halep [ Images ] on the fifth match point.
Australian Stosur was broken by Petrova when serving for the match at 6-5 in the third set and the Russian capitalised by holding her serve and sealing a hard-fought victory 7-5 in the tiebreak.
Stosur had been swept aside by her big-serving opponent in the opening set and then saved one match point in the second set tiebreak before clawing her way back to level the match.
Petrova, beaten 7-6, 6-7, 7-5 by Stosur at last year's US Open in the tournament's longest women's match of the tie-break era, squealed with delight after the Australian pushed a forehand wide to end an encounter lasting nearly three hours.
Petrova, who raised both arms skywards to celebrate her fifth successive appearance in the fourth round at Indian Wells, was delighted to gain a measure of revenge for her defeat at last year's US Open.
The Russian, once ranked as high as third in the world but has now slipped to 33rd, will next meet compatriot Maria Kirilenko, who beat Spaniard Lourdes Dominguez Lino 6-2, 4-6, 6-4.
Sharapova, the 2006 champion, led Halep 6-3 and 5-0 before inexplicably losing her way. The Romanian held for 1-5 and the Russian then squandered three match points on serve before being broken in the seventh and ninth games.
After several protracted baseline rallies punctuated by squeals and grunts by both players, Sharapova finally sealed victory on her fifth match point when Halep netted a backhand.
"I started rushing and playing long in the second set," said Sharapova, who will next face Italy's [ Images ] Roberta Vinci, a 6-7, 6-0, 6-4 winner against Slovakian Dominika Cibulkova [ Images ]. "Things weren't going my way and it was really tough but I pulled through."
In other matches, seventh-seed Marion Bartoli [ Images ] of France [ Images ] pummeled South African Chanelle Scheepers 6-2, 6-0 and Czech Lucie Safarova [ Images ] advanced when former French Open [ Images ] champion Francesca Schiavone became another victim of the widespread viral infection at Indian Wells.