Rep. Justin Amash, R-Mich., comments about the vote on the defense spending bill and his failed amendment that would have cut funding to the National Security Agency's program that collects the phone records of U.S. citizens and residents, at the Capitol. The Amash Amendment narrowly lost, 217-205. The White House and congressional backers of the NSA's electronic surveillance program lobbied against ending the massive collection of phone records from millions of Americans saying it would put the nation at risk from another terrorist attack. (ASSOCIATED PRESS / J. Scott Applewhite)

WASHINGTON (AP) — After 9/11, there were no shades of gray. There are plenty now.

The vigorous debate over the collection of millions of Americans’ phone records, underlined by a narrow House vote upholding the practice, buried any notion that it’s out of line, even unpatriotic, to challenge the national security efforts of the government.

Democrats and Republicans, conservatives and liberals, joined in common cause against the Obama administration’s aggressive surveillance, falling just short Wednesday night against a similarly jumbled and determined coalition of leaders and lawmakers who supported it.

It’s not every day you see Republican Speaker John Boehner and Democratic leader Nancy Pelosi facing off together against their own parties’ colleagues — with an assist from Rep. Michele Bachmann, no less — to help give President Barack Obama what he wanted. But that’s what it took to overcome efforts to restrict the National Security Agency’s surveillance program.

After the Sept. 11, 2001, terrorist attacks, President George W. Bush warned the world “either you are with us or you are with the terrorists,” period, and those few politicians who objected to anything the U.S. wanted to do for its national security looked like oddballs.

That remarkable political consensus cracked in the bog of the Iraq war, and argument returned, but the government has had little trouble holding on to its extraordinary counterterrorism tools.

What’s changed?

The passage of time, for one thing, and the absence of another attack on the scale of 9/11. Americans have also discovered, through Edward Snowden’s leaks, that surveillance doesn’t start at the water’s edge or stop with terrorist plotters in the homeland, but sweeps in the phone records of ordinary people indiscriminately.

Even in the frightening aftermath of 9/11, when large majorities told pollsters they were ready to trade in some personal protections for greater security, any effort to monitor phone calls or emails of average people was considered a step too far. In a Pew Research Center survey the week after the terrorist attacks, 70 percent said no to that.

Republican Sen. John McCain of Arizona says memories of those days have faded and the political climate has changed.

“The stuff we went through last year about detainees we never would have gone through in 2002,” he said Thursday. He was referring to the debate in Congress for two years straight over the indefinite detention of terrorist suspects, even U.S. citizens captured within the nation’s borders.

The closeness of the House surveillance vote “says there’s great and widespread concern about the extent of the NSA’s activities,” McCain said, “and that’s why we need hearings in Congress.” This, from a supporter of the NSA surveillance.

Concerns about drone use domestically, as well as the NSA’s powers, have energized the debate in Congress, though they have hardly rolled back the national security apparatus. Lawmakers have prevailed repeatedly on votes to keep Guantanamo open for terrorist suspects and, on Wednesday, the House easily passed a nearly $600 billion defense spending bill once the air cleared from the surveillance showdown.

Public opinion appears to have shifted toward privacy but in measured ways.

A Washington Post-ABC News poll released Wednesday found rising concern about threats to privacy, with a majority saying the NSA’s collection of phone and Internet data intrudes on people’s rights.

Yet 57 percent said it’s more important for the government to investigate terrorist threats, even at a cost to privacy, than for it to put privacy first. In 2002, that view was held even more strongly, by 79 percent.

Ever since the 2001 attacks, Congress has authorized and presidents of both parties have signed extensions of the powers to search records and conduct roving wiretaps in pursuit of terrorists, tools provided by the USA Patriot Act. The act passed in October 2001 with only one vote against it in the Senate, and with a lopsided 357-66 vote in the House.

Two years ago, it won yet another strong endorsement, renewed despite a delay achieved by Sen. Rand Paul of Kentucky, a tea party favorite though first and foremost a libertarian when it comes to the government exercising its national security powers.

The clash over the surveillance program Wednesday was the first chance for lawmakers to act since the breadth of the government’s monitoring was exposed in classified documents leaked by Snowden, the former NSA systems analyst.

Rep. Mike Rogers, R-Mich., chairman of the House Intelligence Committee, implored fellow lawmakers to support the program, asking: “Have 12 years gone by and our memories faded so badly that we forgot what happened on Sept. 11?” In opposition, Republican colleague Rep. Jim Sensenbrenner of Wisconsin said the collection of phone records exceeds anything he foresaw when he helped to write the Patriot Act, and should be stopped.

In a sign of the program’s iffy prospects, Boehner took the unusual step of casting a vote — he normally doesn’t — to help keep it alive. The program survived on a vote of 217-205, capping a bipartisan struggle won by 134 Republicans and 83 Democrats joining in favor of the operation.

Against it: 94 Republicans and 111 Democrats — losers of the vote but outliers no more.