At issue is a law passed in 2008 - known as Section 702 of the Foreign Intelligence Surveillance Act (FISA) - that allows the NSA to collect texts and emails of foreigners overseas without an individualized warrant, even when they communicate with Americans in the U.S.
The measure, passed 256-164, would extend Section 702 of the Foreign Intelligence Surveillance Act through 2023.
The US House of Representatives passed a crucial surveillance law Thursday that reinforced the ability of the country's spy agencies to intercept and make use of Americans' private communications.
The bill now goes to the Senate, where Goodlatte said it would pass.
The program is set to expire on January 19 unless Congress acts. Rand Paul, R-Ky., appeared on Fox News where he said he spoke with the president about his own concerns surrounding FISA, and said the president indicated he would back reforms put forward by Amash and Paul himself.
"House votes on controversial FISA ACT today", he tweeted.
Donald Trump suggested on Thursday that a key program to collect foreign intelligence could have been used by the Obama administration to "badly surveil and abuse" his campaign.
But later, Trump seemed to reverse course: "With that being said, I have personally directed the fix to the unmasking process since taking office and today's vote is about foreign surveillance of foreign bad guys on foreign land. We need it! Get smart!" On Wednesday, the White House issued a statement opposing changes to the program.More news: More cases in E. coli outbreak
More news: Margot Robbie and Chris Hemsworth hilariously battle to be the 'Best Aussie'
More news: Mob angered by rape, murder of girl attacks police
The reauthorization bill, S. 139, isn't directly related to the unmasking issue. Goodlatte said the bill does have meaningful reforms, and he would have preferred more, but that the option was not between a flawless bill and letting the FISA section sunset.
Communications companies represented by the Computer & Communications Companies were not please with the amendment's failure or the bill's passage. House Speak Paul Ryan called President Trump following his first tweet of the morning, according to a source familiar with the call.
"A vote for this (Nunes) bill is a vote against the Fourth Amendment", said Jason Pye, FreedomWorks' vice president of legislative affairs.
The Trump administration and the intelligence community want to preserve the program as-is.
Demand Progress, a civil-liberties focused advocacy group, condemned the House for voting down the amendment.
"We think that is unconstitutional, hugely problematic, and we're here to defend the rights of the American people", Amash said.
Later, Director of National Intelligence Dan Coats' office said he issued guidance allowing "unmasking" the identities of USA citizens caught up in foreign surveillance only if authorized by intelligence agency heads or someone designated by them. And last month, CIA Director Mike Pompeo, a former congressman from Kansas, warned that allowing the program to lapse would return the United States "to a pre-9/11 mindset in terms of how we conduct our intelligence sharing". They are not using this data to prosecute Americans for tax evasion, they say - they are using it for terrorism cases. Mark Warner of Virginia, the top Democrat on the Senate Intelligence Committee, said on Twitter.
GOP leaders chose to bring the Nunes bill to the floor rather than legislation passed by the House Judiciary Committee that supporters say had stronger privacy provisions.
"The House-passed bill does absolutely nothing to defend the vast majority of law-abiding Americans from warrantless searches, and in many ways it expands the federal government's ability to spy on Americans".