"The Chinese government conducts necessary management over the Internet. It is the same with other nations," foreign ministry spokesman Liu Jianchao told journalists.
"You cannot deny, some websites actually contain content that violates China's laws."
Liu cited websites that maintain that Taiwan is an independent nation separate from China, a view that violates China's anti-secession law, he said.
"I hope that websites can practise self-restraint and not do things that violate China's law," he said.
Liu was responding to questions on why websites belonging to the BBC, the Voice of America and Reporters Without Borders appeared to be blocked in China after they were made accessible during the Beijing Olympics.
Liu did not answer those questions, nor would he comment on the legal process leading up to the blocking of any particular website.
China exercises strict control over the Internet, blocking sites linked to Chinese dissidents, the outlawed Falun Gong spiritual movement, the Tibetan government-in-exile and those with information on the 1989 Tiananmen massacre.
Its system of Internet censorship has become known as the "Great Firewall of China" due to the large number of websites that are inaccessible from inside the country.