Protesters shout slogans as they protest against an anti-conspiracy bill outside parliament building in Tokyo.
Photograph: Issei Kato/Reuters

Japan has passed a controversial law targeting conspiracies to commit terrorism and other serious crimes, despite a warning by the UN that it could be used to crack down on civil liberties.

The ruling Liberal Democratic party and its junior coalition partner pushed the bill through the upper house of Japan’s parliament as thousands of people protested outside.

The vote on the bill, which has been delayed three times amid widespread public opposition, came after a UN expert called the legislation “defective”, eliciting an angry response from Japan’s prime minister, Shinzo Abe.

Officials in Tokyo insist the law is needed to ratify a 2000 UN treaty targeting global organised crime, and to improve Japan’s anti-terrorism measures as it prepares to host the rugby world cup in 2019 and the Olympics the following year.

“It’s only three years until the Tokyo Olympics and Paralympics and so I’d like to ratify the treaty on organised crime as soon as possible so we can firmly cooperate with international society to prevent terrorism,” Abe told reporters. “That’s why the law was enacted.”

The legislation would criminalise plotting and preparing to commit 277 “serious crimes”.

But the Japan Federation of Bar Associations and other critics point out that offences covered by the law include those with no obvious connection to terrorism or organised crime, such as sit-ins to protest construction of apartment buildings or copying music.

Opponents see the legislation as part of Abe’s broader mission to increase state powers, and fear ordinary citizens could be targeted, despite government assurances to the contrary.

Renho Murata, leader of the opposition Democratic party, said Abe’s administration had pushed through a “brutal” law that would infringe on freedom of thought.

Critics fear that the law, combined with a widening of legal wiretapping and the reluctance of courts to limit police surveillance powers, could deter grassroots opposition to government policies.

To try to speed up passage of the law, the ruling bloc took the rare, contentious step of skipping a vote in an upper house committee and moving directly to a vote in the full upper house.

Joseph Cannataci, the UN special rapporteur on the right to privacy, wrote to Abe last month asking him to address the risk that the changes could “lead to undue restrictions to the rights to privacy and to freedom of expression”.

Abe described Cannataci’s assessment as “extremely unbalanced” and said his conduct was “hardly that of an objective expert”.

Cannataci said on Thursday that the Japanese government had used “the psychology of fear” to push through “defective legislation”.

He added: “Japan needs to improve its safeguards for privacy, now even more so that this suspicious piece of legislation has been put on the statute books.”

Critics say gathering information on possible plots would require expanded police surveillance, and the legislation has been compared to Japan’s “thought police”, who before and during the second world war had broad powers to investigate political groups seen as a threat to public order.

A Kyodo news agency survey last month showed voters are split over the bill, with support at 39.9% and opposition at 41.4%.

An estimated 5,000 people demonstrated in front of the parliament building, denouncing the new law as “autocratic” and vowing to prevent Japan from turning into a “surveillance society”.

“Peaceful demonstrations could be prohibited for being viewed as terrorism,” Miyuki Masuyama, a 54-year-old woman, told Kyodo news. “Our freedom of expression will be threatened.”