A US appeals court has reinstated a lawsuit, brought by civil liberties and other groups, challenging the legality of a controversial government law allowing the surveillance of residents' telephone calls and email messages.

The Court of Appeals for the Second Circuit, in an opinion issued Monday, overturned a lower court ruling that threw out a lawsuit challenging the constitutionality of the FISA (Foreign Intelligence Surveillance Act) Amendments Act of 2008. The US Congress passed the FISA Amendments Act in response to news reports of widespread surveillance of US residents by the National Security Agency under the administration of former President George W Bush.

The American Civil Liberties Union, Amnesty International and other groups immediately challenged the FISA Amendments Act in a lawsuit. But in August 2009, District Court Judge John Koeltl of the Southern District of New York dismissed the case, saying the plaintiffs had no right to challenge the new surveillance law because they could not prove their communications had been monitored under the secret programme.

Koeltl's ruling created a "Catch 22," the ACLU said in a press release. But the appeals court ruled that the plaintiffs have standing to challenge the law, which they say violates the US Constitution.

The law "has put the plaintiffs in a lose-lose situation: either they can continue to communicate sensitive information electronically and bear a substantial risk of being monitored under a statute they allege to be unconstitutional, or they can incur financial and professional costs to avoid being monitored," the three judge panel wrote. "Either way, the [FISA law] directly affects them."

The plaintiffs have a "reasonable fear" of being spied upon, the judges wrote.

The ACLU praised the appeals court ruling. The lawsuit will now go back to a trial court.

"The government's surveillance practices should not be immune from judicial review, and this decision ensures that they won't be," Jameel Jaffer, the ACLU's deputy legal director, said in a statement. "The law we've challenged permits the government to conduct dragnet surveillance of Americans' international communications, and it has none of the safeguards that the Constitution requires."

Supporters of the FISA Amendments Act argued the legislation put new safeguards in place to protect US residents against the NSA programme, started in response to the 2001 terrorist attacks, and against other government spying. But the ACLU argued the law gave the US government "virtually unchecked power" to spy on international phone calls and email messages.

The law was also controversial because it gave telecom carriers that participated in the NSA surveillance programme immunity from lawsuits.

President Barack Obama's administration has defended the law in court, and has argued that FISA courts are a way to review government surveillance programmes.