The National Security Agency's warrantless and wide-ranging spying programme is to continue after congressmen voted down an amendment aimed at limiting its surveillance activities.

The House of Representatives voted 217-205 on Wednesday to defeat an amendment to a defence bill that would have limited the NSA's power to collect electronic data to individuals under investigation.

It also would have ended "authority for the blanket collection of records under the Patriot Act".

The vote, tabled by Republican congressman Justin Amash, was the first held on limiting NSA spying since Edward Snowden leaked documents detailing its extensive secret surveillance programme known as Prism.

The US president, Barack Obama, who has spoken out in defence of the programme and said Prism had prevented more than 50 "terrorist" plots, sent the NSA chief, General Keith Alexander, to Capitol Hill on Tuesday night to urge both Republican and Democratic politicians to oppose the move to restrict the agency's activities.

'We fight on'

Amash tweeted after the vote: "We came close (205-217). If just 7 Reps had switched their votes, we would have succeeded. Thank YOU for making a difference. We fight on."

Earlier in the day, he tweeted: "When's the last time a president put out an emergency statement against an amendment? The Washington elites fear liberty. They fear you."

Carney said Obama was still open to discussing the balance between security and privacy with Congress and Americans - but that he wants an approach that properly weighs what intelligence tools are needed to keep Americans safe.

"Any amendments to defund the programme on appropriations bills would be unwise," said a Tuesday statement from Democratic Senator Dianne Feinstein and Republican Saxby Chambliss.

The Prism revelations caused an international uproar against what many view as an invasion of privacy.

Numerous countries, including Germany and Brazil, have also spoken out against the programme.

Tea Party conservatives, liberal Democrats and libertarians - such as Amash - all backed the proposed amendment.