The second-seeded Russian led 2-0 in the final set but 18-year-old Radwanska, seeded 30, won six straight games to clinch the biggest victory of her career.
"I had nothing to lose, just hit every ball, and I did it," Radwanska told the crowd.
While Sharapova struggled on serve in breezy conditions and produced 12 double faults, Radwanska stood well inside the baseline to return serve and snatched the first set by the odd break.
The second seed won eight successive games to lead 2-0 in the final set but Radwanska stormed back to hand Sharapova her earliest grand-slam defeat since she lost in the third round at Flushing Meadows in 2004.
"I knew that she hates it if somebody moves when she is serving," Radwanska said.
"So I knew I had a chance if I did it and she made so many errors on her second serve."