William Binney spent more than 30 years at the National Security Agency designing programs that enabled mass surveillance of foreign terrorists.

Weeks after the 9/11 attacks, Binney retired in disgust when he saw the agency using that technology to spy on every American.

Since then, he has agitated for reining in unconstitutional invasions of privacy. At first he worked behind the scenes. Binney decided to go public after his actions resulted not in reform but retaliation, including being accosted at gunpoint by an FBI agent raiding his Maryland house. He began telling his story to journalists in 2011, two years before the stunning revelations of NSA contractor Edward Snowden.

Last week, Binney brought his warnings of a growing “totalitarian state” to an unlikely venue: the Bent Creek Golf Club in Eden Prairie, where about 80 Libertarians, antiwar activists and others gathered to hear from the second-best-known NSA whistleblower.

Wednesday’s visit was a timely one. The day before, Congress had imposed the most significant limits on the federal government’s surveillance power in more than 30 years. The USA Freedom Act, quickly signed by President Obama, introduces more accountability for the secret court that grants spying powers and restricted the NSA’s collection of data from telephone companies.

Binney called it a “step in the right direction,” but far short of what he thinks would make federal officials change their ways: “We’d have to put them in jail. That’s the way to stop all this crap.”

Binney, Snowden and other whistleblowers are heroes to those who have watched the growth of the surveillance state with alarm. In “Citizenfour,” the 2014 documentary about how Snowden leaked NSA records to journalists, there’s a scene of Binney arriving at the German parliament last year to testify about NSA spying. In Berlin, Binney got a celebrity’s welcome, which he attributes to the still-fresh memories of the Stasi, East Germany’s secret police.

Binney noted that he has never been invited to testify before Congress, although he regularly communicates with members and staffers on Capitol Hill. His long career with the NSA lends him credibility, not to mention a command of the many programs and policies that enable the NSA to capture vast quantities of Internet and telephone data.

Binney volunteered for military service during the Vietnam War, but his value in intelligence was quickly recognized. He worked as a “crypto-mathematician,” an expert in encrypted communication, and was credited with helping develop a system that could track individuals by correlating huge amounts of data from Web searches, GPS locations, credit card payments and the like.

He said his system had safeguards to protect the Fourth Amendment rights of Americans. But after the Sept. 11, 2001, terrorist attacks, the NSA jettisoned those safeguards, he said.

“I’m kind of semi-responsible for giving them the capability of what they’re doing today,” he said.

In 2002, Binney and others filed a complaint with the Department of Defense over what they saw as wasteful, ineffective and illegal surveillance technology. He thinks that made him a target after the New York Times reported in 2005 about the NSA’s mass warrantless wiretapping program, a story made possible by a leaker that the Bush administration was determined to punish.

Simultaneous federal raids on Binney and other former intelligence staffers took place on July 26, 2007. Binney said he was getting out of the shower when an armed FBI agent came into his bathroom.

Binney said that after three attempts to charge him with something, he received a letter of immunity from the Department of Justice in 2010 and hasn’t been troubled by them since. Nevertheless, Binney doesn’t see much distinction between the Bush and Obama administrations when it comes to intelligence policy.

Instead of settling into retirement, Binney has told his story around the world, alerting the public about the power of his former employer to exploit the expanding electronic trail of our lives.

“I’m out here exposing their underwear,” he said.

Contact James Eli Shiffer at james.shiffer@startribune.com or 612-673-4116. Read his blog at startribune.com/fulldisclosure.