Image copyright AFP Image caption Armed police stood guard in the Sanlitun area of Beijing on 26 December in response to warnings of a possible terror threat

China has passed controversial new anti-terrorism laws, saying they are needed to combat growing threats.

The new laws, passed on Sunday by China's legislature, create a new anti-terror agency and security forces with significant powers.

Critics say the laws are too broad and can be used against dissidents and religious minorities.

China has blamed Muslim Uighur separatists from Xinjiang for several public attacks in recent years.

Last week several Western governments issued warnings for foreigners in Beijing's Sanlitun neighbourhood citing intelligence of a possible threat there.

Analysis - Stephen Evans, BBC News, Beijing

Image copyright AFP Image caption One of the more prominent public attacks China has seen in recent years was the 1 March 2014 knife attack at a Kunming train station

Under the new law, China will have a single counter-terrorism body which the country's public security ministry says "will be in charge of identifying terrorist activities and personnel, and coordinate nationwide anti-terrorist work".

The official Chinese media cited a knife attack which left 29 people dead at a train station in 2014 as giving greater urgency to the the legislation.

The attack by four assailants was widely attributed to a Uighur group, the mainly-Muslim minority in the western Xinjiang province.

The Chinese government is keen that the undoubtedly tough measures it takes there are viewed as "counter-terrorism" (similar to measures taken by Western countries) rather than as the oppression of an ethnic minority.

The law will also give the authorities greater rights to monitor private communications. Just like in other countries, the government says this will not infringe liberty.

Read more: Why is there tension between China and the Uighurs?

What are the new measures?

State media report that a new counter-terrorism agency and a national intelligence centre will be set up. Professional anti-terrorist forces will also be established

Telecommunications and internet providers will have to "provide technical support and assistance including decryption", and will be made to "prevent dissemination of information" on extremism

Police forces can now use weapons directly in "emergency circumstances" when facing attackers with guns or knives

The military can now also venture overseas on counter-terrorism operations

Disseminating information about terrorist activities is now banned, as is fabricating stories about fake terror incidents

Except for pre-approved news media outlets, nobody is allowed to report on a terror attack nor the authorities' response, online and offline

Why are the laws controversial?

Image copyright AFP/Getty Images Image caption Authorities said Xinjiang separatists were behind an October 2013 incident where a car crashed near Tiananmen Gate in Beijing

Human rights groups say the laws are too broad and sweeping, and could be used to crack down on dissidents as well as religious minorities.

Amnesty International said in March, while the laws were still being drafted, that they have no safeguard to prevent those practicing their religion or criticise the government from being "persecuted on broad charges related to 'terrorism' or 'extremism."

Human Rights Watch also said the laws are not in line with international standards, and pointed out that the new agencies would have "enormous discretionary powers".

Prominent Chinese dissident Hu Jia tweeted on Monday of the new laws: "What it is used for is not terrorism, but rather in the name of combating terrorism, it attacks all kinds of protests, particularly group and street protests. It creates all kinds of emergency situations where it can monitor and severely restrict citizens and groups."

What is China's defence?

Image copyright AFP Image caption The far western province of Xinjiang is home to a significant population of the Muslim Uighur community in China

China has repeatedly said that it faces legitimate terror threats and that the laws are needed to combat them. It has also denied repressing Uighurs and other minorities.

Li Shouwei, a spokesman for China's legislature, told reporters on Sunday that the laws do not target any specific region, ethnicity or religion.

Chinese commentators have long accused the West of double standards, saying that the West has refused to acknowledge the public attacks as terrorism by characterising them as human rights conflicts.

But many of the public attacks, particularly those in Xinjiang, have been difficult for news media to independently verify as China severely restricts foreigners' travel into such areas and the flow of information during such incidents.

China has also said that its new laws would not impinge on internet freedom and intellectual property rights.