The 18-year-old from Great Britain followed up her victory over Kim Clijsters in round two, which sent the Belgian into retirement, by upsetting another former grand slam champion.
Li, who won the French Open last summer, looked favourite to come through when she recovered from losing the opening set to level, but Robson did not waver and deservedly clinched a 6-4 6-7 (5/7) 6-2 win.
The Londoner had come close to big wins before, particularly in two meetings with Sharapova, one at Wimbledon last year and the other at the Olympics a month ago.
Robson said: "I have just worked hard over the last few weeks and I feel like I'm playing very well.
"I have had lots of tough matches against some very experienced opponents so, the way that I see it, it was time to startwinning a few of them."
It was a hugely disappointing loss for Li, who has been one of the form players on the north American hard courts, and she felt she had contributed to her downfall.
She said of Robson: "She has a huge first serve but it's not like I didn't have a chance.
"I was making a lot of mistakes in the whole match, so I gave her a lot of free points. That made her like, 'Oh, I've got more confidence. Oh, I can beat her.'"
In the next round Robson will play another of last year's grand slam winners in Stosur, who was given a tough time in the first set by America's Varvara Lepchenko before easing away to win 7-6 (7/5) 6-2.
Sharapova has breezed through the draw so far and her 6-1 6-1 victory over American college player Mallory Burdette made it only seven games lost in three matches.
The only slight negative for the third seed was a few problems with her serve in the windy conditions, but she was reasonably content.
Sharapova said: "Of course I would have loved to have served a little better in that second set today. I gave her that break but overall it was pretty solid. Considering the conditions I thought I served good and placed the ball well."
The 25-year-old, meanwhile, confirmed that she split up from her fiance, basketball player Sasha Vujacic, in the spring.
Sharapova said: "It was obviously a challenging decision from both of our ends.
"It was a really nice period of time for both of us but our career schedules just made it extremely difficult to see each other with the travelling, and especially his career move to Turkey."
Sharapova will next meet a fellow Russian, 19th seed Nadia Petrova, who defeated Czech Lucie Safarova, the 15th seed, 6-4 7-5.
Former Wimbledon champion and fifth seed Petra Kvitova has not dropped a set yet, the Czech seeing off France's Pauline
Parmentier 6-4 6-4 to set up a meeting with 11th seed Marion Bartoli, a 6-2 6-4 winner over fellow Frenchwoman Kristina Mladenovic.
One hour and 39 minutes was all it took for defending champion Novak Djokovic to book his place in the third round.
The Serbian, looking to end the year on a high in terms of majors, saw off Rogerio Dutra da Silva in straight sets on Arthur Ashe, beating the unheralded Brazilian 6-2 6-1 6-2.
Fourth seed David Ferrer continued his straightforward progress through the draw with a 6-2 6-3 7-6 (14/12) victory over Dutch qualifier Igor Sijsling.
There was a popular victory, meanwhile, for American college champion Steve Johnson, who served his way to a 6-7 (3/7) 7-6 (7/5) 6-3 6-4 win over mercurial Latvian Ernests Gulbis.
Johnson, a 22-year-old wild card, becomes the first college champion to reach the third round of the US Open since Sargis Sargsian in 1995.