In other drama, Venus Williams fell to Russian teenager Anastasia Pavlyuchenkova, whose 3-6, 6-1, 6-4 victory was her second over the American in a week, while Novak Djokovic fired 10 aces in a 6-3, 7-5 win over Romania's Victor Hanescu to advance to the second round.
Having lost the first set to the 20-year-old Zhang, Safina found herself 5-4 behind in the second. She battled back to force the tiebreak, but with the crowd and momentum behind the local player, Zhang held firm to take the match.
According to the points reckoning, Safina would lose her No. 1 ranking to Serena Williams if she finished behind the American, who won her first round match on Saturday against Estonia's Kaia Kanepi and next faces Russian Ekaterina Makarova on Tuesday. Safina can hold on to the top ranking if Serena loses.
The latest defeat comes a week after Safina was knocked out of the second round of the Toray Pan Pacific Open by 18-year-old qualifier Chang Kai-chen from Taiwan.
Zhang, ranked 226th in the world, said close losses in the past to high-ranking players gave her confidence that she could win at their level.
"I woke up this morning feeling really excited, but didn't do any special preparation and never expected to win the match," she said.
However, Safina, who racked up 13 double faults, was also "not in the best condition and made too many errors," Zhang said. Safina, who had begun shouting and growing visibly more distraught toward the end of the match, did not speak to reporters.
In the previous match on center court, Pavlyuchenkova, who turned 18 in July, finished up with a comeback victory over Serena's older sister Venus.
The American got off to a strong start against the Russian who defeated her in the second round in Tokyo last week, taking the first set 6-3. But she dropped the second and then scrambled to recover in the third to no avail.
Serving for the match, Pavlyuchenkova sent a decisive forehand winner past a reaching Williams to wrap up the final set after two hours, 13 minutes of play.
"She played really well. Sometimes I just made errors too soon in the point," said Williams, who totaled 12 double faults for the match.
Asked if there was something about the Russian's game that she found difficult to handle, Williams declined to analyze.
"She plays well against everyone she plays and I think I ususally do too," Williams said.
Pavlyuchenkova said she'd learned from her defeat to Williams earlier this year in Dubai that she had to take the game to her opponent, applying that to last week's match in Tokyo.
"I just tried to play as simple as I can just into the court and just make her move and today I just tried to do the same thing," Pavlyuchenkova said.
"She started actually way aggressive today especially the first set. She was playing much better, she was already preparing for this match more ... she wanted to kill me I guess," she said with a smile.
Second-seeded Djokovic took just one hour, 29 minutes to claim the win, despite some inventive play at the net by the 27th ranked Hanescu.
A key moment came in the first set when, up 4-2, Djokovic saved two break points to hold serve and remain in control. The second set began with the players trading breaks to two games apiece. Each then held serve until Djokovic broke Hanescu to go up 6-5 and served out for the match.
"I was happy overall with the way I played. It's just that I thought I could finish the job earlier. It was a little bit frustrating the way I was losing some points in the second set," world No. 4-ranked Djokovic said. "That's the first round. You have to get used to the ups and downs a little bit and hopefully the next match will be more consistent and I'll be able to play my best," he said.
On Tuesday, No. 2 Rafael Nadal and defending China Open champion Andy Roddick start their campaigns in the men's draw.