7-9 minutes - Source: BBC
It is set to criminalise secession, subversion and collusion with foreign forces, but will also effectively curtail protests and freedom of speech.
The move follows increasing unrest and a widening pro-democracy movement.
Veteran activists have already said they will march on Wednesday, despite the risk of arrest under the new law.
But the Demosisto pro-democracy organisation, spearheaded by one of Hong Kong's most prominent activists, Joshua Wong, announced on Facebook on Tuesday it was ceasing all operations. Mr Wong had earlier said he was leaving the group.
China has not yet officially confirmed the law has been passed and no draft was made public beforehand, meaning residents are still unclear of the measures they will have to abide by. The law could be implemented as early as Wednesday.
Hong Kong was handed back to China from British control in 1997, but under a special agreement that guaranteed certain rights for 50 years.
So the law has drawn harsh international condemnation and also sparked demonstrations in Hong Kong since it was announced by Beijing in May.
China says the law is needed to tackle unrest and instability and rejects criticism as interference in its affairs.
What does the new law do?The BBC has been told that the law went through unanimously in a session of the Standing Committee of the National People's Congress in Beijing.
It is expected to be added to Hong Kong statute books later in the day and comes a day before the 23rd anniversary of the handover from Britain to China - a date usually marked by pro-democracy protests.
It would make criminal any act of secession, subversion of the central government, terrorism and collusion with foreign or external forces.
A new office in Hong Kong would deal with national security cases, but would also have other powers such as overseeing education about national security in Hong Kong schools.
In addition, the city will have to establish its own national security commission to enforce the laws, with a Beijing-appointed adviser.
Hong Kong's chief executive will have the power to appoint judges to hear national security cases, a move which has raised fears about judicial independence.
Importantly, Beijing will have power over how the law should be interpreted. If the law conflicts with any Hong Kong law, the Beijing law takes priority.
How will it change Hong Kong?For many, the law undermines the freedoms that set Hong Kong apart from the rest of China and helped define its character.
People in Hong Kong prize civil liberties such as free speech, the right to protest and an entirely independent and robust judiciary, as permitted in its mini-constitution, the Basic Law, agreed when the territory's sovereignty was returned to China in 1997.
In recent years, Hong Kong has seen waves of protests demanding more rights. Last year, rallies over a now-scrapped law permitting extraditions to the mainland turned violent and fuelled a broad pro-democracy movement.
Chief Executive Carrie Lam says the new law is a "responsible" move to protect the law-abiding majority.
She has said that Hong Kong's freedoms, vibrancy and core values will be preserved.
'A tool to suppress political agitation'Analysis by Stephen McDonell, BBC China correspondent
Hong Kong's sweeping new security law is a frighteningly open-ended tool to suppress political agitation.
Like similar laws on the Chinese mainland it appears that it can be manipulated to meet the needs of the Communist Party as required to crush almost any action deemed threatening.
Unlike elsewhere in China, Hong Kong has an independent judiciary. For this reason, the Party's leadership was not going to leave interpretation of this law in the hands of just any old judges.
No. Those who'll be allowed to preside in these matters will be hand-picked by Carrie Lam, the city's leader who was effectively installed by Beijing.
So, prior to the new security bill, which actions by activists - no matter how subversive - could not be dealt with under existing laws? What were "extremists" getting away with to warrant this new legislation?
Bomb making? No. Smashing up buildings? No. Meeting with international NGOs to talk about the city's deteriorating freedoms? Ahhhh. Perhaps. Publicly advocating Hong Kong independence? Almost certainly.
The more that Beijing, under Xi Jinping's leadership, has sought to control Hong Kong, the more it has driven residents into the pro-democracy camp.
But he is playing a long game. Sure, handover promises to the UK were made but he was not going to let some Western attachment to liberty trump loyalty to the motherland. Not on his watch. Enter the security law.
What has the reaction been?Democratic Party leader Wu Chi-wai said he would defy a police ban on Wednesday's "handover day" march.
He will be joined by Figo Chan, of the Civil Human Rights Front, who urged people to take to the streets, saying: "We are aware of the risks of being prosecuted. But we insist on taking the lead, as we want to tell Hongkongers not to fear."
Police plan to have 4,000 riot officers on standby, the South China Morning Post reports.
Rights group Amnesty International has described the law as "the greatest threat to human rights in the city's recent history".
Taiwan on Tuesday even warned its citizens of risks in visiting Hong Kong.
But there was widespread international criticism even before the law was passed.
The European Parliament voted to take China to the International Court of Justice in The Hague should the law be imposed.
The UK said it would change its immigration rules and offer millions of people in Hong Kong "a route to citizenship" if China went ahead with the legislation.
Washington on Monday began moves to end Hong Kong's special status trade relationship with the US.
On Tuesday, China said it would respond to the removal with unspecified "countermeasures".