The decision was 4-2. Justices Elena Kagan and Sonia Sotomayor recused themselves because they dealt with the case in their previous jobs. Justice Neil Gorsuch was not on the bench when the case was argued.
The long-running civil rights lawsuit filed by immigrants in 2002 against the former Bush administration officials argued the plaintiffs were racially profiled and illegally detained after the attacks.
After the attacks, FBI dedicated more than 4,000 special agents to arrest and detain 762 non-citizens on charges that they had violated federal immigration laws.
In court papers, the government argued that "in light of their immigration status, it was ... lawful to arrest and detain them pending their removal."
But the class of about 80 Muslim, South Asian and Arab individuals who were held at the Metropolitan Detention Center in Brooklyn argued that the officials lacked any kind of individualized information that they were dangerous.
The court said the lawsuit had to be authorized by Congress.
"After considering the special factors necessarily implicated by the detention policy claims, the Court now holds that those factors show that whether a damages action should be allowed is a decision for the Congress to make, not the courts," Justice Anthony Kennedy wrote for the court.
Steve Vladeck, CNN Supreme Court analyst and professor of law at the University of Texas School of Law, said the decision "will make it all but impossible for victims of federal constitutional violations to obtain damages in all but the most ordinary of cases."
"The Court has effectively said that, even where constitutional rights are at issue, whether there should be damages remedies is up to Congress, not the judiciary," he said.
Rachel Meeropol, an attorney for the challengers, argued they were mistreated through a policy "crafted at the highest levels of government, to treat harshly Muslim non-citizens of Arab and South Asian descent, based on the false and pernicious assumption that the individuals with those characteristics might have some connection to terrorism."
They claimed holding them in ultra-restrictive conditions violated their due-process rights.
Justice Stephen Breyer took the unusual step of reading his dissent, joined by Justice Ruth Bader Ginsburg, from the bench. He argued he would have allowed the plaintiffs' claims to go forward, and he noted the plaintiffs were "shackled," "slammed against walls" and "verbally abused."
"History tells us of far too many instances where the executive or legislative branch took action during time of war that on later examination, turned out unnecessarily and unreasonably to have deprived American citizens of basic constitutional rights," he said.
This story is breaking and will be updated.