The 19-year-old Sprem, ranked No. 30, outplayed Williams on Centre Court 7-6 (5), 7-6 (6) in the first major surprise of the championships.
Chair umpire Ted Watts incorrectly called the score as 2-2 in the second-set tiebreaker, giving Sprem a point when instead she should have been taking a second serve.
Both players appeared confused, but neither disputed the call.
Tournament referee Alan Mills confirmed the umpire made a mistake but said the result would stand.
It's the earliest defeat for Williams at a Grand Slam tournament since a first-round loss at the French Open in 2001. It's also her earliest exit from Wimbledon since going out in the opening round in 1997.
Williams, who won Wimbledon in 2000 and 2001 and lost in the last two finals to her sister, Serena, didn't blame the scoring error for her defeat. She had plenty of chances to force a third set, but blew three set points and lost the last five points.
"I don't think one call makes a match,' she said.
The Williams match overshadowed victories by Andy Roddick, Roger Federer, Lleyton Hewitt and Goran Ivanisevic and a second-round defeat for former nine-time champion Martina Navratilova.
The 47-year-old Navratilova, playing singles at Wimbledon for the first time in 10 years, lost 3-6, 6-3, 6-3 to Gisela Dulko the same player who beat her in the first round of the French Open last month. Navratilova received a long ovation from the Court 3 crowd as she sat on her chair. She stood and waved to acknowledge the applause.
Ivanisevic, recreating some of the magic of his improbable run to the 2001 title, pulled out a five-set victory to set up a third-round showcase against former champion Hewitt.
The Croatian, who missed Wimbledon the last two years with injuries and is retiring after these championships, was his usual animated self as he came up with the big shots at the right time to outlast Italy's Filippo Volandri, 4-6, 7-6 (8), 1-6, 6-3, 6-4.
After closing out the match with a service winner, Ivanisevic stuck out his tongue and tossed his racket into the crowd. He then stripped off his shirt and tossed it into the stands, basking in a huge ovation from fans.
Hewitt, who won the 2002 championship after the Croatian was unable to defend his title because of a shoulder injury, defeated Georgia's Irakli Labadze 6-4, 6-4, 6-1.
Federer, the top-seeded defending champion, beat Colombian qualifier Alejandro Falla 6-1, 6-2, 6-0 in just 54 minutes one of the fastest men's matches in recent Grand Slam history to sweep into the third round.
The second-seeded Roddick took advantage of an early start and a break in the weather to finish off a 6-3, 7-5, 6-4 win over Taiwan's Wang Yeu-tzuoo in a match suspended by rain at 4-2 in the first set Tuesday.
Also advancing was third-seeded Guillermo Coria, who completed a match that stretched over four days. The French Open runner-up needed just two points and two minutes to finish off a 6-4, 6-7 (3), 6-3, 6-7 (3), 6-3 win over 106th-ranked Wesley Moodie of South Africa.
But the day will be remembered most for Williams' loss.
She was leading 2-1 in the second tiebreak when Sprem's first serve was wide and called out by the line judge. Williams casually hit the ball back and Sprem hit a backhand into the open court with Williams standing still, figuring the point was over.
Watts called the score 2-2, but the players lined up in the same positions for what should have been a second serve. Indeed, Sprem hit a 86 mph serve, and Williams hit a backhand return winner.
That should have made the score 3-1, but Watts called it 3-2.
Williams still squandered a big chance to even the match. She moved out to a 6-3 lead, giving her three set points. Sprem erased the first with a forehand passing winner and Williams wasted the second with a double fault and the third with a forehand into the net. Williams slipped and let out a shriek.
At 6-6, Williams' forehand volley hit the top of the net but fell back on her side, giving Sprem her first match point. The match ended on the next point when Williams hit a forehand long.
Asked whether she considered questioning the score, Williams said, "Yes, but I didn't want to lose my focus. At the time, I felt that maybe I had lost track, or couldn't be sure.' "I'm not an arguer either,' she added.