Image copyright Reuters Image caption PM Najib ended indefinite detention without trial in 2012 - but the new law brings it back

Malaysia has passed a controversial anti-terrorism bill, which the government says is needed to tackle the threat from Islamic extremists.

The bill reintroduces indefinite detention without trial - something the prime minister had repealed in 2012.

Human Rights Watch called the move "a giant step backwards for human rights".

It was passed hours after the police announced the detention of 17 suspected militants believed to be planning attacks in the capital, Kuala Lumpur.

Home Minister Zahid Hamidi said those arrested, the youngest just 14, were planning to attack police stations and army bases to gather weapons.

Two of the suspects had just returned from Syria, police said.

'Grievous blow'

Debate on the anti-terrorism bill went late into Monday night in parliament.

Under the legislation, suspects can be held without trial for up to two years, with multiple extensions allowed after that. Decisions on their detention will be made by a terrorism board, rather than the judiciary.

Image copyright AFP Image caption Malaysia is worried about the effect of nationals fighting with Islamist militants in the Middle East

It also allows the authorities to revoke travel documents, both Malaysian and foreign, of people travelling to or from Malaysia to support or engage in terrorism.

The bill still needs approval from the Senate, but the chamber is dominated by the ruling coalition and it is expected to pass.

Malaysia scrapped its Internal Security Act - which permitted indefinite detention without trial - in April 2012 amid public concern it was using the legislation to stifle political debate and lock up critics.

But it replaced the colonial-era law with powers that permitted 28-day detention.

Opposition lawmaker N Surendran, quoted by AFP news agency, said the new anti-terror law was "open to abuse and is a grievous blow to democracy".

Image copyright EPA Image caption Cartoonist Zunar is one of several government critics accused of violating the sedition law in recent months

Analysis: Jennifer Pak, BBC News, Kuala Lumpur

Malaysians largely supported Prime Minister Najib Razak's call for an anti-terror bill last year after he revealed that 19 suspects linked to the Islamic State militant group had escaped court charges due to insufficient proof.

But Mr Najib is under pressure from his party also to be tough on government critics after his coalition lost the popular vote in the last election.

In recent months, a number of high-profile dissidents have been detained under the sedition act. Activists say the new bill is another tool to silence opposition.

Officials assure Malaysians that the proposed law cannot be used against people with different political beliefs. But Malaysia's Bar Council says this is a "false comfort" because the bill is vague.

It comes down to trust. And Mr Najib's image as a reformer has taken a battering.

Phil Robertson of Human Rights Watch said that by "restoring indefinite detention without trial, Malaysia has re-opened Pandora's Box for politically motivated, abusive state actions".

Malaysia - a Muslim-majority nation - says it is concerned about the effect on domestic security of those who have fought with or support Islamic extremists in Syria and Iraq.

In January, Home Minister Datuk Seri Dr Ahmad Zahid Hamidi said 67 Malaysians were known to have gone to Syria and Iraq, including five who had been killed. One hundred and twenty people suspected of links to the Islamic State militant groups were being held in Malaysia, he said.

But the government has also been clamping down on critics in recent months.

Journalists, activists and opposition figures have all been targeted by the equally controversial sedition law, which regulates speech deemed to incite unrest or religious and social tensions.

Opposition leader Anwar Ibrahim, meanwhile, remains in prison after being convicted of sodomy - an act which is illegal in Malaysia but for which few are ever prosecuted.

He says the case against him is aimed at keeping him out of politics.