In the case of Ex Parte Milligan, in 1866 the Supreme Court overturned the conviction by a military court of Lambdin Milligan. Milligan, an Indiana resident, was opposed to the U.S. going to war against the Confederacy.
The late Chief Justice William Rehnquist wrote about Milligan's case in his 1998 book All the Laws But One: Civil Liberties in Wartime. Rehnquist notes that civil courts were available, but the decision to instead go to a military court was seen as "the more expeditious mode". That procedural decision was pivotal in the Supreme Court case.
Rehnquist describes the relative lack of defendants' rights in military trials. For example, the charges against them were stated in more general terms than would be allowed in the civil courts. The defendants were not notified of the specific acts they were alleged to have committed.
Milligan was found guilty of treason in 1864, and was sentenced to be hanged.
The Supreme Court, in considering Milligan's appeal in 1866, the year after the Civil War ended, noted the different climate in which they were operating:
During the late wicked Rebellion, the temper of the times did not allow that calmness in deliberation and discussion so necessary to a correct conclusion of a purely judicial question. Then, considerations of safety were mingled with the exercise of power, and feelings and interests prevailed which are happily terminated. Now that the public safety is assured, this question, as well as all others, can be discussed and decided without passion or the admixture of any element not required to form a legal judgment. We approach the investigation of this case fully sensible of the magnitude of the inquiry and the necessity of full and cautious deliberation.
The Court was thereby acknowledging that it doesn't operate in a vacuum. It takes notice of events such as wars, and the ending of wars, when considering cases.
The Court decided that the military court had no jurisdiction to try Milligan because he was a civilian, and the state (Indiana) in which he was tried was one in which the regular federal courts were operational, and was not in rebellion.
The Supreme Court has repeatedly acknowledged the need to suppress certain civil liberties in wartime, but has never given the Executive Branch a blank check in that regard. Litigation arising from the current undeclared war on Al Qaeda fits in with that tradition.
The title of Rehnquist's book comes from a statement to Congress by Abraham Lincoln, early in the Civil War. Justifying the suspension of the writ of habeas corpus (the type of legal action by which a prisoner can seek to be freed if unlawfully detained) Lincoln said he would not allow "all the laws, but one, to go unexecuted, and the government itself go to pieces, lest than one be violated."