WASHINGTON -- The Supreme Court on Monday upheld a federal law that forbids providing training and advice to terrorist organizations even about entirely peaceful and legal activities, saying it does not violate free speech rights.

The court ruled 6-3 that Congress and the executive branch had legitimate reasons for barring "material support" to foreign organizations deemed to be terrorists.

Those challenging the law "simply disagree with the considered judgment of Congress and the executive that providing material support to a designated foreign terrorist organization -- even seemingly benign support -- bolsters the terrorist activities of that organization," Chief Justice John G. Roberts Jr. wrote.

He was joined by the court's conservatives as well as its most liberal member, retiring Justice John Paul Stevens.

Justice Stephen Breyer took the relatively unusual step of reading his dissent from the bench, saying the court had abandoned its role of protecting individual liberties under the First Amendment because of national security threats Congress did not adequately justify.

"In such cases, our decisions must reflect the Constitution's grant of foreign affairs and defense powers to the president and to Congress but without denying our own special judicial obligation to protect the constitutional rights of individuals," Breyer said.