The razor-thin defeat of a congressional measure to rein in domestic surveillance galvanized civil libertarians on Thursday for what they expect to be a drawn-out political and legal struggle to clip the wings of the intelligence apparatus in the US.

While a measure by Representative Justin Amash, a Michigan Republican, failed in the House on Wednesday night, the tight vote was the closest that privacy advocates have come since 9/11 to stopping the National Security Agency from collecting Americans' data in bulk.

Members of Congress, liberties groups and former surveillance officials pointed to a variety of measures, from new legislation in both the Senate and House to court cases, as means to reset the much-contested balance between liberty and security in the US over the coming weeks and months.

"There are many voices concerned in the Senate about this same issue," said J Kirk Wiebe, a former senior NSA analyst turned whistleblower. "It doesn't mean it's the end of it. It's the beginning."

Aides to congressman James Sensenbrenner, the Wisconsin Republican who wrote the Patriot Act, told the Guardian on Thursday that he plans to introduce legislation through the House judiciary committee that would restrict the NSA's bulk surveillance of Americans' phone records.

"Yesterday's amendment was only a first step in what will be a long debate," said Sensenbrenner spokesman Ben Miller.

Barbara Lee

A tally of the votes shows that a majority of Democrats voted in favor of the amendment. One of them, Barbara Lee, told the Guardian that the "stage was now set" to curb the NSA. "It was a great beginning – a first step," she said.

"I can tell you why I voted for it – and most Democrats have the same sentiment – we have to a balance between civil liberties and national security, and I believe this was a very carefully crafted and balanced amendment. Right now, we must rein in the NSA," she said.

Representative Keith Ellison, co-chairman of the congressional progressive caucus, expressed disappointment that the Amash amendent did not pass. "For the government to just collect people's data without any sense of that individual warrants or merits and investigation of some kind is a problem. I am pretty disappointed we didn't pass it, but I am pretty impressed with how well we did. This issue is not over. There will be more voters and there will be more bills. I feel confident we can perhaps prevail."

'It is time for us to renew the Patriot Act'

He urged a full review of the Patriot Act, passed in the wake of 9/11 and which authorises some of NSA's contentious surveillance activities. "We had a horrific event that happened with 9/11. We responded as people do when they are faced with a crisis like that. We passed a piece of legislation, without much review or consideration, in order to try to regain some sense of security. It has been over ten years now – it is time for us to review the Patriot Act."

In the wake of the House vote, intelligence officials acknowledged that the debate in Congress and beyond over the phone records collection was not over.

Shawn Turner, the director of communications for national intelligence, said: "As foreign surveillance discussions continue and Congress makes decisions about authorities exercised by the NSA, the intelligence community will remain committed to demonstrating our compliance with the rule of law and respect for the civil liberties and privacy of every American.

"As the director of national intelligence has made clear, we welcome a healthy public dialogue about transparency and national security, and are hopeful that careful consideration of the impact to the safety and security of our nation will precede any changes to existing laws."

During a heated debate on the House floor late Wednesday afternoon, one of the Amash amendment's lead opponents, intelligence committee chairman Mike Rogers, pledged to insert "additional privacy protections" to the bulk phone-records program in his forthcoming intelligence authorization bill as a way to drain support from Amash.

Civil libertarians say they intend to hold Rogers to his pledge. "It's important to note that they've had seven years to do this privately and they haven't taken those steps yet, so relying on Rogers to now implement protections should be looked at a little bit skeptically," said Amie Stepanovich, a lawyer with the Electronic Privacy Information Center. "But I think he needs to be pushed on that issue. Now that he's made the public claim that he plans to do that, we need to follow up and make sure he takes that a step forward."

In the Senate, a bill introduced late last month by Pat Leahy, the Vermont Democrat who chairs the judiciary committee, would shorten the lifespan of the Patriot Act and compel the government to "show relevance to an authorized investigation and a link to one of three categories of a foreign agent, power, or group," thereby blocking the bulk surveillance. Leahy plans to hold a hearing on the NSA on Wednesday, just before Congress recesses for August.

Pointing to Leahy's bill, Stepanovich predicted that the close vote over the Amash amendment "is going to resonate in the Senate".

The tight margin on the Amash amendment came despite a rare concerted effort of both the Republican and Democratic leadership, which heavily pressured their caucuses to vote against it.

John Boehner, the House Speaker, who voted no to the amendment, said on Thursday: "I wanted the House to have this debate. We did. The amendment was defeated. I'm proud of my colleagues who stood up for what I think they believe is a program to help protect the American people."

On the Democratic side, pressure to vote for the bill was similarly intense.

A Democratic staffer for a pro-Amash legislator said Nancy Pelosi, the Democratic leader, over-stated the impact of the amendment during a Wednesday morning meeting with members, saying it would "completely defund the surveillance programs," when it only dealt with the bulk surveillance NSA conducts under Section 215 of the Patriot Act. Pelosi, a former House intelligence committee chairwoman, voted against the amendment.

Congress is not the only venue for challenges to the NSA bulk surveillance. Lawsuits filed in New York and California federal courts by the ACLU and the Electronic Frontier Foundation challenge the legality and constitutionality of the phone records dragnet.

The Justice Department has already argued in New York that the phone records collection cannot be challenged in court unless litigants can prove not merely that their phone data was collected but that it was analyzed by NSA, a standard that would make the program unreviewable since the analysis occurs in secret. A preliminary hearing in the ACLU case was taking place on Thursday.

Additionally, the NSA and the Obama administration has pledged to work to declassify opinions of the secret surveillance court, known as the Fisa court, that would offer transparency into the legal regimes the court believes govern the bulk surveillance.

Judge Reggie Walton, the presiding judge of the Fisa court, has given the Justice Department until Monday to provide a timetable for declassifying orders for records related to a lawsuit filed by Yahoo, that the technology company says will demonstrate that it was compelled to participate in the surveillance.

Beyond the courts, activists alarmed by the bulk surveillance are looking to hold pro-surveillance legislators accountable for the Amash vote.

"First, we're working to determine how to put pressure on a handful of very conspicuous members who voted the wrong way – some new members who ran purporting to be progressive, or the group of 17 Democrats who voted against the Patriot Act in 2011 but voted against Amash yesterday," said David Segal of Demand Progress, a progressive group opposed to the bulk surveillance.

"We hope that as many people as possible will continue to call and email their members of Congress to thank those who voted the right way and demand that others change their votes."