The upper house of parliament passed the conspiracy bill early on Thursday after political wrangling through the night, overcoming the weak opposition’s no-confidence motion against Prime Minister Shinzo Abe’s cabinet and a censure motion aimed at Justice Minister Katsutoshi Kaneda.
The bill passed the more powerful lower house last month – Abe’s ruling coalition has a comfortable majority in both houses.
But rights groups, Japan’s national bar association and numerous academics have opposed the bill, saying it is so broad it could be abused to allow wiretapping of innocent citizens and threaten privacy and freedom of expression guarantees in the constitution.
US surveillance whistleblower Edward Snowden and Joseph Cannataci, UN special rapporteur on the right to privacy, have both criticised the law.
It has also sparked regular street protests nationwide.
The government argues that the legislation is necessary to prevent terrorism ahead of the 2020 Olympic Games in Tokyo.
Officials also say it is a prerequisite for implementing a UN treaty against transnational organised crime which Japan signed in 2000.
The bill was revised several times over the years as earlier versions met with fierce resistance and never made it through parliament.
The latest bill reduced the number of targeted crimes to some 270 offences and narrowed the definition of terrorist and criminal organisations.
Earlier versions of the law targeted more than 600 crimes unrelated to terrorism or crime syndicates. Japan’s bar association argued, however, that the current law still gives police and investigators too much leeway in deciding what constitutes a criminal organisation. The general public could be targeted on conspiracy charges via monitoring phone and online conversations, it warned. Some Japanese media have likened the bill to the World War II-era “public order maintenance law” under which ordinary people were arrested for political offences, exercising labour rights and anti-war activities.