By Mark Meadows
The American, seeded seventh after serious health problems which had kept her out of action for almost a year, succumbed 6-3 7-6 after making a succession of unforced errors on Court One.
"I think I did really well, just being able to come back and play and win some matches and just really play tough," she told a news conference.
"Even though today I lost, I was able to kind of hang in there and play tough. I can only get better. That can potentially be really scary, because I can only go up from here and I can just do so much more."
Serena, famous for her steely determination, showed her emotional side in her first-round win over Aravane Rezai when she wept with relief following a long road back to fitness after a cut foot and blood clot on the lungs.
"I never came here thinking I would lose. That's, you know, my attitude," she added twirling her hair in her fingers.
"My mentality was just to do the best that I could and just continue that. Today I tried to do well and I think Marion played really well. Clearly she played really well."
The 2007 runner-up took the first set on her sixth set point and she continued to move the 13-times grand slam champion ruthlessly around the court to move to the brink of victory.
She had three match-points in the 12th game of the second set but Williams showed all her battling qualities and great composure to save them and force a tiebreak.
Bartoli continued to serve strongly and she earned another two match points, the first of which Williams saved with an ace, but the Frenchwoman took the second to take the tiebreak 8-6.
"You cannot say because I beat Serena I'm going to win the whole thing. It's just not working like that," said Bartoli, who banished her parents from the court during her gruelling third round win over Flavia Pennetta.
"Well, I suffered the most definitely against Flavia. I mean, that one was crazy. But I think today the way I played and the way I handled the pressure, especially the pressure, was good."
(Editing by Ed Osmond)