"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 co-operate with worldwide society to prevent terrorism", the prime minister said.
The government also said the legislation is needed to ratify a United Nations treaty on global organized crime, though critics said it could empower the authorities on surveillance and endanger civil liberties.
The ruling Liberal Democratic party and its junior coalition pushed the bill through the upper house of Japan's parliament as thousands of people protested outside.
Japan expert Lim Tai Wei of the National University of Singapore's East Asian Institute said the recent terror attack in Manchester has given Tokyo the impetus to pass a law that can ensure the Olympics - seen as its "coming-out party" after the 2011 quake and tsunami - can be "executed with minimal problems and challenges".
Japan's more powerful lower house passed the bill last month.
Critics are also saying that the gathering of 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 perceived as a threat to the public order.
Arab states don't seek 'regime change' in Qatar
Saudi Arabia and its allies have put enormous pressure on Qatar to meet their demands. The four countries have given Doha a 10-day deadline to meet the demands.
Terrorism "won't disappear because of this law", said 29-year-old demonstrator Yohei Sakano outside parliament.
"Three years ahead of the Tokyo Olympic and Paralympic Games, we hope to cooperate with the worldwide community to prevent terror", he added.
Opposition Democratic Party leader Renho, who goes by only one name, made a statement that deemed the legislation "brutal" and a violation of free thought. Chief Cabinet Secretary Yoshihide Suga said the letter was "inappropriate" and denied that the law would lead to excessive surveillance. A survey carried out by Kyodo news in May noted support for the legislation at 39.9 percent versus 41.4 percent against it. More than 77 per cent said further explanation was needed.
This is Tokyo's fourth attempt to pass the contentious law, which punishes 277 crimes. He added that he had identified "significant worrying signals" in Japan's record on freedom of expression, the Guardian reported.
Demonstrations were also held elsewhere in Japan including in Fukushima Prefecture in northeastern Japan and Kagoshima Prefecture in southwestern Japan, where rallies drew about 500 protesters each. Others are concerned that he may take his eye off the ball when it comes to reviving the economy or dealing with Japan's sliding population.
"The party has to have a debate on what to prioritise, be it social policy, economic policy or the constitution".
- Republicans, Democrats Play Ball for 'Team Scalise'
- House Democrat: 'We need new leadership'
- Cable auto snaps in Gulmarg, 5 die, 4 from one Delhi family
- Safety Experts Raise Red Flag on Snapchat's Newest Feature
- Mourinho wants this player instead of Ronaldo
- Shuttler Srikanth wins Australian Open Super Series title
- 'Transformers: The Last Knight' debuts to a franchise low
- Toll from Pakistan tanker fire climbs to 148
- Trump breaks with tradition, forgoes Ramadan dinner
- Jeremy Corbyn gets rock star welcome at Glastonbury Festival