Protesters on Saturday pushed their way through a paramilitary police cordon to the gates of the ambassador's residence, shouting "Japanese pig come out".
About 500 paramilitary police holding plastic shields raced into the compound and barricaded the gates. "Chinese people shouldn't protect Japanese," the protesters shouted.
Many Chinese resent Japan's wartime aggression, and anti-Japan sentiment has been running high in China since Tuesday when Japan approved a textbook critics say whitewashes wartime atrocities.
Demonstrators, who said they had been organised mostly through email and instant messaging, had been marching peacefully under heavy police guard.
One group began throwing bottles and stones when they passed a Japanese restaurant, smashing windows with tiles they had ripped from its roof before police stopped them. A second restaurant was targeted later in the evening, with rocks thrown through the window, terrifying kimono-clad waitresses.
Protesters attacked Japanese
businesses in Beijing
"We are all Chinese in here and were just minding our own business," one said after the attack.
Protesters also attacked a Bank of Tokyo-Mitsubishi branch and smashed windows before police moved in.
Another group outside the embassy in southeast Beijing threw stones and plastic water bottles smashing windows in the compound. Some demonstrators scuffled with police.
The violence prompted an official protest in Tokyo. Japan's Kyodo news agency said the Chinese foreign ministry had expressed regret for the violence, quoting the Japanese embassy.
"The fact people took actions such as throwing rocks at the ambassador's residence as well as the embassy is not something that the Chinese government can accept," Chinese Vice- Foreign Minister Qiao Zonghuai was quoted as saying.
There have been anti-Japan
protests across China
"Representing the government, I offer my heartfelt sympathy and express my regret."
By late Saturday night, the number of protesters had fallen to several dozen.
Turned back at Tiananmen
Earlier, a crowd of about 1000 protesters was turned away from marching to the political heart of Beijing, Tiananmen Square, where a pro-democracy student protest was crushed with massive loss of life in 1989.
The crowd, singing and chanting, was turned back towards the Japanese embassy which was guarded by a line of city police and behind them five lines of riot police with shields.
"Representing the government, I offer my heartfelt sympathy and express my regret"
Chinese Vice-Foreign Minister Qiao Zonghuai
The demonstration started in the Beijing neighbourhood of Zhongguancun, known for its electronics shops and home to a large student population, and comes less than a week after anti-Japanese protests in other Chinese cities turned violent.
"Japan doesn't face up to its history," said Cheng Lei, 27, an information technology professional. "We want to express our feelings so the Japanese government knows what we think."
The official Xinhua news agency put the number of protesters early in the day at more than 10,000.
Large-scale protests are rare in China, where the Communist leadership is concerned about maintaining stability at a time of social change and a widening gap between rich and poor.
Past demonstrations outside the Japanese embassy have typically been heavily policed, choreographed events involving about 50 people, with short speeches.
Protests in China are rare
Last week, protesters smashed windows at a Japanese supermarket in southwest Chengdu after a demonstration there against Japan's bid for a permanent Security Council seat.
Protesters also took to the streets in Guangzhou, Chongqing and the southern city of Shenzhen. The media said 20 million Chinese signed an online petition opposing the UN seat bid.
Some protesters wore red signs pasted to their chests bearing a traditional Chinese dragon and reading "Reject Japanese goods". Others began kicking a Toyota car caught in the middle of the crowd before it managed to drive away.
"Across the country, the mood to refuse Japanese goods is high, but nothing has been done about this. Therefore, patriotic students have organised themselves," said a notice circulated by email on Friday urging people to protest.
Japanese corporations sunk $9.2 billion into China in 2004, highlighting the financial ties at stake should the Chinese government heed the citizens in the streets and take a more strident line in dealing with the Japan.