With US Secretary of State John Kerry watching from a second-row seat behind a baseline, the fifth-seeded Williams wasted a 4-1 lead in the final set and was broken while serving for the victory at 5-3.
Williams is the first tennis player to participate in singles at five Olympics, and never had failed to reach at least the third round before, claiming a gold at the 2000 Sydney Games.
She also won doubles golds in 2000, 2008 and 2012.
But against Flipkens, who was making her Olympic debut, Williams failed to find the right measure on most of her strokes and wound up with 13 fewer winners.
Williams, once possessor of one of the best serves in women's tennis, hit one ace, five fewer than Flipkens.
The crowd couldn't seem to settle on which woman it wanted to win. They greeted Williams far more loudly and warmly during pre-match introductions, although perhaps that was because of her far-greater name recognition.
Later, though, they roared when Williams made mistakes. They clapped when she double-faulted. They even gave her grief for the common and innocuous practice of catching a ball toss that wasn't good.
When one group of spectators bellowed a "USA! USA!" chant late in the third set, others responded by booing (Kerry had left by then).