The House voted down an amendment Wednesday to its version of the Department of Defense's 2014 budget that would have banned funding to NSA surveillance programs such as PRISM by a slim 12 vote margin.

The amendment, the first major legislative test since the once secret programs were made public by Edward Snowden, was defeated 205-217.

Initially proposed by Rep. Justin Amash (R-Mich.) the amendment sought to ban any funds from the Department of Defense's 2014 budget from being directed to the NSA for surveillance of anyone not actually under investigation by law.

As the two minute vote ran out of time on the floor, House Speaker John Boehner was heard just off the House floor saying loudly, "I like all those no votes." In an unusual move for any House speaker, especially on an amendment, Boehner voted No.

The amendment had support and opposition from both sides of the aisle. Michigan Democrat John Conyers introduced the bill along with Amash. There were more than 40 co-sponsors of the bill, including some of the House's most liberal and most conservative representatives.

House Intelligence Committee Chair Rep. Mike Rogers (R-Mich.), who in recent days has been one of the strongest voices against the amendment, said during a debate before the vote that passing the bill "takes us back to September 10th," diminishing the military's ability to keep tabs on terrorists.

Rep. Tom Cotton (R-Ark.) closed the debate echoing Rogers sentiments.

"This program has stopped dozens of terrorist attacks," Cotton said. Adding, "this amendment blows it up."

But Rep. Mick Mulvaney (R-S.C.), a co-sponsor of the amendment, argued that the NSA's surveillance programs, which collect metadata of calls and emails but not their actual content, ought to be banned because those who "balance" control of what gets recorded and what doesn't are unelected and anonymous.

"Right now the balancing is being done by people who we do not know, who we do not elect," he said.

The Senate is expected to present their mark up of the budget sometime next week.