A federal judge in Idaho has ruled that the United States, after the Sept. 11 terrorist attacks, wrongly imprisoned an American under a law designed to keep trial witnesses from fleeing and that since there was evidence that the government may have willfully misused the law against him, his case should go to trial.

Judge Edward J. Lodge, who was appointed by President George Bush, issued his rulings late on Thursday in the longstanding case of Abdullah al-Kidd, an American who was seized at an airport in 2003, imprisoned for 16 days, repeatedly strip-searched and left naked in his cell. The Justice Department had sought to have his trial request summarily dismissed and denied having misused the law in detaining him.

Mr. Kidd’s lawyer, Lee Gelernt of the American Civil Liberties Union, welcomed the ruling, saying, “It will finally put the government on trial for its post-Sept. 11 practices.”