The Google case could exacerbate tensions between China and the United States, already at odds over the value of the yuan currency, trade disputes and climate change negotiations. It threw a spotlight on hacking and the Internet controls that Google says have frustrated its business in China.
It comes at a time when other foreign businesses have also expressed increasing frustration at China's business climate, even as its economic growth outpaces the rest of the world.
Google, the world's top search engine, said it may shut its Chinese-language google.cn website and offices in China after a cyber-attack originating from China that also targeted other firms, as well as attacks on dissidents using its Gmail service.
The company, which has struggled to compete with local market leader Baidu, said it would discuss with the Chinese government ways to offer an unfiltered search engine, or pull out.
"China's Internet is open and the Chinese government encourages development of the Internet," Foreign Ministry spokeswoman Jiang Yu said when asked to comment on Google.
"China welcomes international Internet businesses developing services in China according to the law. Chinese law proscribes any form of hacking activity."
In an online statement, Minister Wang Chen of the State Council Information Office warned against pornography, cyber-attacks, online fraud and "rumours", saying that government and Internet media have a responsibility to shape public opinion.
The statement said China itself was a victim of hacker attacks, and that Beijing resolutely opposed hacking.
Wang's comments, Beijing's first official reaction after Google threatened to quit China over cyber-attacks, gave no indication that China -- which has the world's biggest number of Internet users at 360 million -- would give ground.
The statement made no direct mention of Google.
The official China Daily described Google's threat as a "strategy to put pressure on the Chinese government".
The dispute drew an outpouring of nationalistic fervour from China's online community, with some "netizens" cheering it as a victory for the Chinese.
Cyber-experts said more than 30 firms were victims of attacks that used tailored emails to deliver malicious software exploiting vulnerabilities in the Adobe Acrobat and Adobe Reader software.
U.S. Commerce Secretary Gary Locke urged China on Wednesday to ensure a "secure" commercial environment for U.S. companies.
"The recent cyber intrusion that Google attributes to China is troubling to the U.S. government and American companies doing business in China," Locke said in a statement.
"This incident should be equally troubling to the Chinese government. The administration encourages the government of China to work with Google and other U.S. companies to ensure a climate for secure commercial operations in the Chinese market," he said.
Google came under pressure from the Chinese government last year and was ordered to change the way it allows searches.
It filters many topics deemed sensitive in China. Most of those filters were still in place on Thursday, although controls over some searches, including the June 4, 1989 crackdown on democracy protesters, appear to have been loosened.
Google trails homegrown rival Baidu in China's $1 billion a year search market, with 30 percent market share to Baidu's 61 percent, according to Analysys International. Baidu shares rose after the Google announcement.
About a dozen Chinese fans of Google held an impromptu candlelight vigil at the company's Beijing headquarters late on Wednesday. Others had brought bouquets of roses and lilies shortly after Google's decision was announced.
He Ye, a woman at the vigil, said finding alternative news would become more difficult if Google pulled out of China.
"If I cannot search for it through Google, I'd feel I lose a part of my life," she said.
A comment on the website of a Chinese-language tabloid, the Global Times, said Google was threatening to quit China because it had been beaten by Baidu.
"Our largest Chinese search engine has thoroughly defeated the American leader, and we can again rejoice in the global arena," said the comment. "It also shows that nowhere can we not match up to the United States."