The measure has provoked an outcry from charities and concerns from foreign governments that it gives police wide-ranging discretionary powers amid a crackdown on civil society in the country.
At least 1,000 foreign NGOs are thought to operate in China, including development charities such as Save the Children, advocacy groups including Greenpeace, chambers of commerce and university centres.
The National People's Congress standing committee, which acts as the parliament when the NPC is not in full session, gave the law almost unanimous approval, with 147 votes in favour and only one against.
It covers foreign charities, business associations, academic institutions and others in China, and requires them to "partner" with a Chinese government-controlled agency and report their actions to authorities.
More From This Section
"There have been some foreign NGOs which have planned or carried out activities threatening the stability of society and national security," NPC official Zhang Yong told reporters at a briefing.
Chinese police would have the right to cancel any activities they judged a threat to national security, and would be empowered to "invite for talks" the heads of foreign NGOs in China, Xinhua said.
At the briefing Guo Linmao, another NPC official, dismissed concerns over police supervision, saying: "Ordinary folk have a saying: If you have a problem, call the police, if you haven't broken the law, what are you afraid of?"
Overseas NGOs would also be forbidden from recruiting "members" in mainland China, Xinhua said, barring special permission from the State Council, China's cabinet. It was not specified whether that included local staff.
"We are also deeply concerned about the provisions in the draft Law on Foreign NGO Management," Hans Dietmar Schweisgut, the European Union ambassador to China, wrote in a letter earlier this year seen by AFP.