A US judge has ruled that a US NSA (National Security Agency) programme to wiretap telephone and internet traffic of US residents is illegal and must be stopped.

On Thursday Judge Anna Diggs Taylor of the US District Court for the Eastern District of Michigan ordered the NSA "and its agents, employees, representatives and any other persons or entities in active concert or participation" with the agency to halt the so-called Terrorist Surveillance Program.

The scheme allowed the NSA to monitor communications between US residents and people in other countries with suspected ties to terrorist group Al Qaeda, without getting court-ordered warrants.

The programme, authorised by US president George Bush in 2002, violates the US Constitution's guarantees of freedom of speech and association and its prohibitions against unreasonable searches and seizures, Taylor wrote in her order. The NSA programme also violates the separation of powers clause in the Constitution, she wrote, as well as the Foreign Intelligence Surveillance Act, which set courts to issue warrants for wiretaps focused on counterintelligence.

"The public interest is clear, in this matter," Taylor wrote. "It is the upholding of our Constitution."

Bush has defended the scheme as a valuable tool used to track down potential terrorists. The programme is "firmly grounded in law" and only targets international phone calls in which one participant is suspected to be linked to Al Qaeda, Bush spokesman Tony Snow said in a statement.

"We couldn’t disagree more with this ruling," Snow added. "The whole point is to detect and prevent terrorist attacks before they can be carried out. That's what the American people expect from their government, and it is the president's most solemn duty to ensure their protection."

The US DoJ (Department of Justice) yesterday said it has already appealed against Taylor's order. The NSA programme "is a critical tool that ensures we have in place an early warning system to detect and prevent a terrorist attack", it said in a statement. Taylor's order to shut down the programme will be delayed until after a hearing to determine whether the ruling should be postponed until the appeal process ends, the DoJ said.