(CNN) -- The Supreme Court has dismissed a lawsuit brought by a lifelong U.S. citizen who was held in jail for 16 days by the federal government as a "material witness" in an ongoing terror investigation.

Abdullah al-Kidd was never charged and never called to testify, but the justices, by an 8-0 vote Tuesday, said the Kansas native cannot hold former Bush administration officials -- in particular, onetime Attorney General John Ashcroft -- personally liable for wrongful arrest and detention.

The decision is a victory for the government's efforts to detain those with potential links to terrorism.

Material witness laws allow officials to detain those who may have knowledge of crimes committed by others to ensure they will testify in legal proceedings, including grand jury sessions and trials.

American Civil Liberties Union lawyers representing al-Kidd say the government had warped the law to allow open-ended arrests and confinement of citizens without anyone being later held accountable for those wrongfully held.

But Justice Antonin Scalia wrote, "Even assuming -- contrafactually -- that Ashcroft's alleged detention policy violated the Fourth Amendment, he deserves qualified immunity. A government official's conduct violates clearly established law when, at the time of the challenged conduct, (it is) sufficiently clear that 'every reasonable official would have understood that what he is doing violates that right.' The constitutional question in this case falls far short of that threshold."

The appeal -- with its issue of the limits of "preventive" detention, especially after the 9/11 terror attacks -- is the only national security case the high court will address this term.

The ruling was narrow, addressing only the immunity question, not the often shaky boundaries of material witness warrants.

Al-Kidd was a college football player at the University of Idaho when he converted to Islam, changing his name from Lavoni Kidd. He eventually began volunteering at an Islamic charity led by a person being investigated for possible terrorism ties.

He was never implicated in wrongdoing, but was interviewed repeatedly and voluntarily by the FBI. He was never told his testimony would be needed in any prosecution, nor was he forbidden to leave the country.

Six months later, in March 2003, al-Kidd was about to board a plane at Dulles International Airport outside Washington, headed for Saudi Arabia to do study for a doctorate. But he was arrested by government agents armed with a material warrant. An affidavit submitted to a federal magistrate said that al-Kidd had a one-way, first-class plane ticket and that he was "crucial" to the prosecution of Sami Omar al-Hussayen.

It was later revealed the ticket was two-way -- indicating he planned to return to the United States -- and he would fly coach class.

In his lawsuit, al-Kidd says he was held in prisons in Virginia, Oklahoma and Idaho, under high security with convicted criminals. He says he was routinely shackled, strip-searched and left naked in a freezing cell while male and female guards watched.

He was freed after more than two weeks, but only after agreeing to surrender his passport and confine his travel, among other conditions. He now teaches in Saudi Arabia and did not attend oral arguments at the high court.

Al-Hussayen, meanwhile, was charged with visa fraud and making false statements. He was acquitted one some of the charges, but a jury deadlocked on others. He agreed to be deported to avoid a retrial.

Al-Kidd later sued corrections officials; that suit was settled out of court. But it is his separate claim against Ashcroft, holding him personally accountable as head of the Justice Department, that is the heart of the current legal fight.

A federal appeals court had allowed his civil lawsuit to continue, but Ashcroft said officials under his supervision obeyed the letter and spirit of the material witness law. An arrest warrant was properly obtained under the law, they said, and even if there were improper motives behind this particular detention, Ashcroft would still enjoy "absolute" immunity.

The justices had split to some degree on whether the initial detention order was valid.

"The warrant authorizing al-Kidd's arrest named al-Kidd and only al-Kidd," Scalia said.

But Justice Ruth Bader Ginsburg warned about potential government abuse of the law, either through willfulness or negligence.

Al-Kidd's legal "challenges to the brutal conditions of his confinement have been settled," she wrote in a separate concurring opinion. "But his ordeal is a grim reminder of the need to install safeguards against disrespect for human dignity, constraints that will control officialdom even in perilous times."

Previous lawsuits by a variety of civil liberty and human rights groups naming Ashcroft and other top Bush officials -- including Vice President Dick Cheney, Secretary of Defense Donald Rumsfeld and FBI Director Robert Mueller -- have almost unanimously been tossed out by federal courts on immunity grounds.

Justice Elena Kagan is not participating in the case because she helped brief the case for the government last year as solicitor general, just before joining the high court.

Ashcroft had the support of the Obama administration, which argued the case in the high court, as well as several former attorneys general.

But about 30 former federal prosecutors backed al-Kidd.

The case is Ashcroft v. al-Kidd (10-98).