A strict new law governing foreign nongovernmental organizations (NGOs) in China may have some groups packing up and heading home if they can't meet the law's requirements or fall afoul of police who will have increased powers to monitor and control them.

The controversial measure was passed into law on Thursday and will take effect on Jan. 1, 2017, affecting thousands of foreign NGOs.

The new law requires all foreign NGOs to have an official Chinese sponsor or host organization. The groups may not raise funds in China and may not conduct or fund political activities. If police suspect illegal activity, they can shut down NGO events, inspect their offices and finances and question staff at any time.

Foreign governments and rights groups have complained that the new law violates China's legal commitments to freedom of association, and that retarding the growth of civil society could increase economic inequality and social injustice in China.

Ned Price, the U.S. National Security Council spokesman, expressed Washington's concern that the new law "will further narrow space for civil society in China and constrain contact between individuals and organizations in the United States and China."

But Guo Linmao, an official with China's legislature, told reporters at a press briefing in Beijing on Thursday that there's no need to be concerned about the law.

"We welcome and support all foreign NGOs to come to China to conduct friendly exchanges," he said.

Deciding which groups are friendly or hostile will be up to the police. Guo added that the law will clarify the legal status of foreign NGOs, guarantee their lawful rights and make their operations in China more smooth and convenient.

Foreign governments and rights groups say that in addition to the onerous registration requirements, the new law places vague and sweeping restrictions on foreign NGOs — barring them, for example, from doing anything that harms China's national interests, spreads "rumors" or obtains state secrets.

The law's language and focus on national security echo recent warnings from President Xi Jinping and other leaders for Chinese citizens to guard against infiltration, espionage and subversion by foreigners.

Chinese media allege that foreign-funded NGOs, serving as fronts for foreign intelligence services, helped foment the "color" revolutions of the early 2000s in former Soviet states as well as Hong Kong's 2014 pro-democracy " umbrella revolution."

"Although we are open and tolerant, foreign groups that support or manipulate domestic groups to harm China's laws will be dealt with according to the law," Hao Yunhong, a police official in charge of foreign NGOs told reporters at Thursday's press conference.

Peter Dahlin, a Swedish NGO worker with the Chinese Urgent Action Working Group, which trained and supported Chinese human rights lawyers, was detained by Chinese police in January, accused of instigating Chinese to oppose their government.

Dahlin appeared on China's state television to admit his guilt, in what his colleagues said appeared to be a forced confession. He was expelled from the country several weeks after being detained.

David Kelly, a director of research at the Beijing-based firm China Policy, which has advised foreign NGOs on how to deal with Chinese government regulation, says the law's net effect is bad, but hardly unexpected. China's government has been tightening the screws on Chinese and foreign NGOs for several years.

He notes that the law could have been worse, and that the government deleted some stipulations from a draft law after consulting with foreign NGOs. He also points out that there is an important distinction between NGOs that provide services such as education and medicine, and those that engage in advocacy and activism.

The former can usually work out a modus vivendi with the Chinese government, Kelly says. But China was never about to tolerate the latter, especially those perceived as aiming to check the Communist Party's power or hold it to account.

"For foreign NGOs to come in and say, 'We're going to help you set up something which is going to constrain the Chinese state,' well, of course the Chinese state is going to shut it down by any means it can, short of bloodshed," he says.

The bottom line, Kelly says, is that China still needs the expertise foreign NGOs offer.

In China, cycles of repression and easing come and go. And while Kelly sees the law as a step backward, it's not as far back as the era of Chairman Mao, when Kelly says there really was no room for civil society to grow.

Copyright 2016 NPR. To see more, visit http://www.npr.org/.