UPDATE, June 1st: Key provisions of America’s Patriot Act expired at midnight, after the Senate, convening for a rare Sunday session, failed to pass reforms to a controversial programme that allowed the National Security Agency to collect data on Americans’ telephone calls. Senator Rand Paul, a libertarian-leaning Republican who opposes the programme altogether, blocked measures to extend it while his colleagues work out its revision, though he acknowledged their reforms “will ultimately pass”.

DEEP in the desert in Utah, the National Security Agency (NSA), America’s signals intelligence branch, has built a $1.5 billion centre to scoop up and analyse data from the internet. The building includes its own water-treatment facility, electric substation and 60 back-up diesel generators. It will use over a million gallons of water a day. Its data-storage capacity would be enough, according to one estimate, to store a year of footage of round-the-clock video-recording of over a million people. At this centre, communications from across the globe are tapped directly from the fibre-optic backbone of the internet.

And yet even as these data are gathered, America’s politicians are fretfully discussing how much of the pile government snoops can look at, and under what circumstances. Two years after Edward Snowden, a contractor for the NSA, revealed the extent of it, the technical capacity of America’s surveillance state has never been more dramatic. Its legal capacity, however, is becoming markedly more restricted. In Congress and in the courts, the right of the government to collect the data of Americans is being challenged. Politically, the consensus that this level of surveillance (at least of American citizens) is necessary appears to be breaking down.

As The Economist went to press on May 21st, Congress was in a fraught debate about whether and how to renew Section 215 of the Patriot Act—a law passed in the immediate aftermath of the attacks of September 11th 2001—which was due to expire. House Republicans, urged on by Rand Paul, a libertarian-leaning senator who is running for president, were deadlocked with Republican leaders in the Senate. On May 20th-21st Mr Paul spoke against renewal for 10½ hours, arguing that the act damaged both liberty and privacy. Senate leaders, though, worried about hampering the ability of spooks to spy.

Americans are protected against much government spying by the Fourth Amendment, which bans unreasonable searches. They are also buffered by a legal framework first constructed in the 1970s after the bugging and dirty tricks of the Watergate scandal, and the discovery that J. Edgar Hoover’s FBI had spied extensively on suspected communists and civil-rights leaders. Under this system, a federal court (known as the FISA court) exists to issue secret warrants for spying for counter-espionage purposes. Surveillance of Americans or people within America by methods such as wiretaps requires permission from a judge. The Senate Intelligence Committee oversees the court’s decisions.

From the archives: Liberty's lost decade The internet has muddied this picture considerably, however. As Mr Snowden revealed, the capacity of the American state to spy has become spectacularly broad, partly because so much internet traffic travels through America, and so can be easily tapped (something NSA agents call “home-field advantage”). And its legal reach, too, has been far wider than most people were aware of. The Patriot Act, in particular, has allowed more government spying than even its drafters realised. For example, before Mr Snowden’s whistleblowing, few realised that Section 215 of the Patriot Act had a secret legal interpretation which justified the collection of “metadata” of phone calls made by hundreds of millions of Americans. This did not include the content of phone calls, but did include details of who had phoned whom, when, and for how long. Another programme, started under George W. Bush and ended in 2011, collected similar metadata on e-mails sent and received. Other concerns involve Section 702 of the Foreign Intelligence Surveillance Act, which allows the NSA to eavesdrop on communications by people outside the United States. As well as allowing America to spy on foreigners ad libitum, this allows the government to collect inadvertent content in citizens’ communications: for example, if an American has e-mailed a foreigner who is being spied on. All this the government had deemed legal. But on May 7th the Second Circuit Court of Appeals ruled in favour of the American Civil Liberties Union (ACLU) in a case against the government over Section 215. Looking at metadata remains legal, the court ruled, but its “bulk collection” is not. That, says Mark Jaycox of the Electronic Frontier Foundation, a civil-liberties-minded pressure group, is a partial vindication of Mr Snowden’s whistleblowing.

Civil-liberties campaigners are now raising questions about the oversight of the intelligence agencies. “What the Snowden revelations showed…was that the oversight structure is totally broken,” says Neema Singh Guliani of the ACLU. In the FISA court, she points out, there is no advocate for privacy—it is biased in favour of the agencies. Of 34,000 surveillance applications put to the court between 1979 and 2012, only 12 were refused.

Neither, she argues, does the Senate Intelligence Committee’s oversight work properly. The efforts of Senator Ron Wyden, a Democrat on the Senate Intelligence Committee who raised concerns about mass surveillance before 2013, were choked off by more hawkish colleagues. False claims, such as one in 2013 by James Clapper, the director of national intelligence, that the NSA was not collecting data on hundreds of millions of Americans, went unpunished.

A few politicians are beginning to change their tone. Mr Paul, for example, has built a large part of his campaign round the argument that “what you discuss on your phone is none of the government’s business”. He hopes that this message will appeal to young voters who do not trust the feds. It certainly sets him apart from other Republican contenders, who tend to think that the security agencies should have more power, not less.