Attorneys clashed over whether the use of warrantless surveillance is constitutional on Wednesday, during the first review by a federal appeals court of a criminal conviction based on the law underpinning secret spy programs revealed by whistleblower Edward Snowden.

Patrick Toomey, an attorney for the American Civil Liberties Union Foundation, told a court in Oregon that the federal government is bypassing “the fourth amendment rights of Americans like the defendant, while amassing a huge database of their private communications”.

The hearing, in front of a three-judge panel of the ninth US circuit court of appeals in Portland, Oregon, concerned a naturalized US citizen born in Somalia named Mohamed Osman Mohamud.

In 2010, when he was 19, Mohamud plotted to set off what he thought was a powerful truck bomb during a Christmas tree lighting ceremony in downtown Portland, which can draw up to 10,000 spectators.

The 1,800lb device that the young man tried to detonate remotely using a cellphone was actually a fake, designed by federal investigators. Mohamud was described in court as an alleged “Islamic extremist”. After 14 days of trial, a jury found him guilty of “attempting to use a weapon of mass destruction”.

Two years ago, he was sentenced to 30 years in federal prison, followed by a lifetime of government supervision.

But it was not until after Mohamud was convicted that government officials notified his attorneys that agents had relied on Section 702 of the Foreign Intelligence Surveillance Act, which was amended in 2008, to obtain his electronic communications with alleged al-Qaida terrorists without the benefit of a warrant.

The law was later revealed to be used by the US government to justify spy programs disclosed by Snowden, a National Security Agency (NSA) contractor turned whistleblower.

The young man’s attorneys asked for a new trial, arguing that the evidence should be suppressed. The request was denied. Mohamud appealed, and Wednesday’s hearing in Portland was the first time that the statute’s constitutionality was argued before a federal appeals court.

In court on Wednesday, Toomey told the judges surveillance under the FISA Amendment Act, or FAA, “involves the collection of hundreds of millions of communications each year”. The full scope of surveillance under the act was revealed by Snowden, who passed a trove of NSA documents to the Guardian in 2013.

In cases such as Mohamud’s, Toomey said, the government vacuums up that electronic evidence from foreigners without a search warrant and then goes back and picks through it looking for information on specific Americans in so-called secondary or backdoor searches.

That, he said, is a violation of Mohamud’s and other Americans’ constitutional rights.

But he was pressed by the judges about his stand. “Mr Toomey, is your argument based on the premise that even though the government legally procured information through the use of 702, once it had the information regarding a US person, it should not look at it?” one judge asked.

Toomey responded that he did not believe that the “communications were lawfully acquired in the first place”, but added that, “at a very minimum the government should have to seek individualized judicial authorization before it turns around and decides to query a particular American to extract the communications of a particular American from this database”.

But assistant US attorney Kelly Zusman argued that law enforcement agents had not used “a backdoor approach to US persons’ communications. Nothing could be further from the truth”.

Zusman described FISA and FAA as: “Congress’s answer to providing the executive [branch] with a structure and limiting principles for foreign surveillance” and that such surveillance is done with “rigorous internal oversight”.

And “even if were to conclude the statute were unconstitutional”, she told the judges, “our agents relied upon it in good faith.”

In a statement at the time of Mohamud conviction’s, John P Carlin, assistant attorney general for national security, lauded law enforcement personnel, and said the case “highlights how the use of undercover operations against would-be terrorists allows us to engage and disrupt those who wish to commit horrific acts of violence against the innocent public”.