Authorities say the law will strengthen protections for personal information. But it also is likely to curtail the Internet's status as a forum to complain about the government or publicize corruption.
"Their intention is very clear: It is to take back that bit of space for public opinion, that freedom of speech hundreds of millions of Chinese Internet users have strived for," said Murong Xuecun, a prominent Chinese writer.
The rules approved by China's national legislature highlight the chronic tension between the ruling Communist Party's desire to reap technology's benefits and its insistence on controlling information.
Beijing encourages Web use for business and education but tries to block material deemed subversive or obscene. It has steadily stepped up censorship, especially after social media played a role in protests that brought down governments in Egypt and Tunisia.
The latest measure requires users to provide their real names and other identifying information when they register with access providers or post information publicly.
Li rejected complaints that the public will be deprived of a forum that has been used to expose misconduct.
The measure comes amid reports that Beijing might be disrupting use of software that allows Web surfers to see sites abroad that are blocked by its extensive filters.
At the same time, regulators have proposed rules that would bar foreign companies from distributing books, news, music and other material online in China.
The government has given no indication how it will deal with the technical challenge of registering the more than 500 million Chinese who use the Internet.
Microblog operators, two of which say they have more than 300 million users each, were ordered last year to confirm the identities of users but acknowledge they have yet to complete that task.
The main ruling party newspaper, People's Daily, has called weeks for tighter Internet controls, saying rumors spread online have harmed the public.
The secretive ruling party is uneasy about the public's eagerness to discuss politics and sensitive issues online despite threats of punishment.
In March, authorities scrambled to squelch online rumors about a possible coup amid a political crisis that led to the downfall of a prominent party figure, Bo Xilai, ahead of the party's fall leadership transition. A dozen websites were closed and six people detained.
This week, 70 prominent Chinese scholars and lawyers circulated an online petition this week appealing for free speech, independent courts and for the ruling party to encourage private enterprise.
Communist leaders who see the Internet as a promising source of economic growth were slow to enforce the same level of control they impose on movies, books and other media, apparently for fear of hurting e-commerce and other fledgling online businesses.
Until recently, Web surfers could post anonymous comments online or on microblogs.
That gave ordinary Chinese a unique opportunity to express themselves to a public audience in a society where newspapers, television and other media all are state-controlled. Some of the most popular microbloggers have millions of readers.
It also made the Internet a clearinghouse for accusations of official misconduct.
A local party official in China's southwest was fired in November after scenes from a videotape of him having sex with a young woman spread quickly on websites.
Web surfers can circumvent filters by using virtual private networks — encryption software that is used by companies for financial data and other sensitive information. But VPN users say disruptions began in 2011 and are increasing, suggesting regulators are trying to block encrypted traffic.
AP researcher Flora Ji contributed.