Despite stalling tactics by opposition parties, the full upper house approved the bill on Friday by 130 to 82. The more powerful lower house passed the bill last week.
Prime Minister Shinzo Abe, who is seeking to increase Japan's global security role and create a more authoritarian government at home, says the law is needed to protect national security and assuage U.S. concerns over the risks of sharing strategically sensitive information with Tokyo.
Critics worry the law could be used to hinder public disclosures, punish whistleblowers or muzzle the media since journalists could be jailed for seeking information they do not know is classified as secret.
It allows heads of ministries and agencies to classify 23 vaguely worded types of information related to defense, diplomacy, counterintelligence and counterterrorism, almost indefinitely.
Even some members of Abe's Liberal Democratic Party complained that the government rushed too quickly to get the bill approved before the end of the current parliamentary session.
"I think there needs to be more explanation," party member Takashi Uto said. "Naturally people are concerned because they don't know what will be a secret.
In Washington, U.S. State Department deputy spokeswoman Marie Harf said that information security played a critical role in alliance cooperation and that the U.S. welcomed progress "on strengthening policies, practices and procedures related to the protection of classified information."
"A foundation of our alliance is also a shared commitment to universal values, freedom of expression, freedom of the press," she said.
Most objections to the legislation were over human rights implications and over the lack of a guarantee of independent or parliamentary oversight over secrecy decisions. However, during the final debate, lawmakers also questioned how the law might affect civilian employees doing business with government agencies.
"People will be living in a society where they could be punished for not knowing what's secret and what's not," Japan Communist Party lawmaker Sohei Nihi said in arguing against the bill. "Arrests, court judgments, all could be secret. This would violate the constitution."
Foreign businesses engaged in defense contracting, or even companies dealing in "dual-use" technologies and products that have military applications could be affected, said Lawrence Repeta, a law professor at Meiji University in Tokyo.
"If you're in contact with the government, you're at risk of crossing a line even if you don't know there's a line there," Repeta said. "You could be in the position of trying to sell a product that might involve designated secrets. It's something companies have to think about. It's an entirely new area."
Steve Vickers, CEO of Steve Vickers Associates, a risk mitigation and political risk company operating throughout Asia, said that the legislation was mainly aimed at concerns over leaks of sensitive information to China.
The law mandates prison terms of up to 10 years for government officials who leak secrets. Journalists who get information in an "inappropriate" or "wrong" way could be jailed for up to five years. It bans attempted leaks, inappropriate reporting, complicity and solicitation.
Associated Press writer Mari Yamaguchi contributed to this report.