The law broadly defines national security as covering everything from finance and cyber security to religion.
State media said it would "protect people's fundamental interests".
It is part of a raft of policies by President Xi Jinping that have drawn criticism from foreign governments, businesses and rights groups.
The vaguely worded legislation authorises the government to take "all necessary" steps to protect China's sovereignty.
Included in the law, passed by the standing committee of the rubberstamp National People's Congress, is a move to make key network infrastructure and information systems "secure and controllable".
The BBC's Martin Patience in Beijing says critics argue the law is excessive.
Many foreign technology firms operating in China are concerned, he adds. They fear that under the new law they'll be forced to hand over sensitive information to the authorities.
A senior party official, Zheng Shuna, said China's national security situation had "become increasingly severe", the Xinhua news agency reports.
Speaking at a news briefing in Beijing, she said China had to defend its sovereignty and interests while also maintaining its political and social stability.
"We will continue to follow the path of peaceful development but we absolutely will not give up our legitimate rights and absolutely will not sacrifice the country's core interests," she said.
The tightening of security laws comes amid tensions with its neighbours over competing territorial claims in the South China and East China Seas.
President Xi, who is head of the recently formed National Security Commission, has previously said China's security covers a wide range of areas including culture, politics, military, the economy, technology and the environment.
China's legislature has passed a wide-ranging and controversial national security law which tightens government control over many areas of life.