Ahmer Abbasi talks to the Associated Press in Karachi, Pakistan. Abbasi was among several Muslim men who were detained at a federal jail in Brooklyn after the Sept. 11, 2001, attacks. (Fareed Khan/AP)

The Supreme Court considered Wednesday whether high-level U.S. government officials can be held liable for the alleged unconstitutional treatment of a group of noncitizens detained after the terrorist attacks of Sept. 11, 2001.

The long-running case dates to the months after the attacks, when hundreds of Arab and South Asian men — many of them Muslim — were arrested and detained as part of a nationwide terrorism investigation.

Six plaintiffs say they were beaten, strip-searched and treated as terrorism suspects because of their religion and ethnicity. The men, who were not U.S. citizens and lacked lawful immigration status, were held for months in highly restrictive conditions in a federal detention center in Brooklyn, but none were found to have any connection to terrorism.

Two of the court’s liberal justices, Ruth Bader Ginsburg and Stephen G. Breyer, seemed particularly troubled during oral arguments Wednesday about the length of incarceration and treatment of the men months after the Sept. 11, 2001, attacks.

“You know from Day One that many of them have nothing to do with terrorists, and yet you allow that system that might have been justified in October to persist for months and months, when these people are being held in the worst possible conditions of confinement,” Ginsburg said, pressing the acting solicitor general, Ian Heath Gershengorn, who defended the former government officials in the final case argued by the Obama administration.

Breyer suggested that such lawsuits were sometimes necessary as a deterrence at the highest levels of government.

“There’s no blank check even for the president,” he said. “And if there’s no blank check, that means sometimes they can go too far. And if they have gone too far, it is our job to say that.”

The question before the high court is not whether the six men were mistreated but whether they can bring a case for civil damages against high-ranking officials in the administration of President George W. Bush.

Former attorney general John D. Ashcroft, former FBI director Robert S. Mueller III and other officials appealed a divided decision by the U.S. Court of Appeals for the 2nd Circuit in New York that allowed the case to proceed in 2015.

Human rights and immigrant advocates say the outcome of the case is even more significant with the inauguration Friday of ­President-elect Donald Trump because his policy proposals could possibly violate the Constitution. Trump has called for the mass deportation of undocumented immigrants, a ban on new Muslim immigrants and deeper scrutiny of Muslims within the United States.

The shorthanded court was even more so for Wednesday’s argument. Two liberal justices, Elena Kagan and Sonia Sotomayor, recused themselves, presumably because of their earlier work in the solicitor general’s office and on the 2nd Circuit.

In general, government officials are shielded from civil lawsuits seeking financial compensation when they have acted in good faith. The Supreme Court first recognized a limited right for individuals to sue government officials in a 1971 case. Since 1980, however, the court has generally been hesitant to expand that right.

Gershengorn, the acting solicitor general, urged the justices not to order what he said would be a “massive extension.” Congress, not the courts, he said, should decide whether to allow legal challenges to national security and immigration policies.

In the aftermath of the attacks, Gershengorn said the officials were trying “to avoid the inadvertent or premature release of a dangerous terrorist.”

Chief Justice John G. Roberts Jr. seemed to agree, saying it would be an “extraordinary departure” to hold officials personally liable. He suggested that high-ranking officials responding to national emergencies should not be worried about being sued.

“I understand the argument that there are constitutional violations. But the question that you’re asking the court to do is to shape a remedy for that, a remedy that Congress has not provided,” he told Rachel Meeropol of the Center for Constitutional Rights, who argued the plaintiffs’ case.

If the court sides with the government, Meeropol said “there is nothing to deter even more excessive exercises of government power in the future.”

The lawsuit is the third filed against Ashcroft and others to reach the high court involving claims of alleged harsh treatment of Muslims arrested after 9/11.

The court ruled in 2009 that top officials were not liable for allegedly discriminatory actions of their subordinates unless they had ordered the measures. In that case, the court split along ideological lines, with Justice Anthony M. Kennedy siding with Roberts and Justices Clarence Thomas, Samuel A. Alito Jr. and Antonin Scalia, who died last year.

Only one of the men who filed suit, Benamar Benatta, was in the courtroom on Wednesday. Three others were denied visas to return to the United States, according to Meeropol.

Outside the court, Benatta, now a Canadian citizen, said officials should be held accountable. A former soldier with the Algerian military, he came to the United States for a training exercise. Benatta applied for asylum, but said that his visa expired before the application was received.

“It’s easy to label someone a terrorist,” he said, “but it’s something that will haunt you for the rest of your life.”

The case is Ziglar v. Abbasi.

abigail.hauslohner@washpost.com