The first witness had just started testifying yesterday in the case of nine persons arrested last month at the Supreme Court during the annual demonstration against the court's decision legalizing abortion when D.C. Superior Court Judge Joseph Michael Hannon made a startling disclosure.

Hannon told the courtroom, crowded with antiabortion activists, that he and his law clerk, John Ingram, had joined the March for Life Jan. 22, the anniversary of the court's 1973 Roe v. Wade decision.

According to lawyers who were in the courtroom, Hannon -- who was trying the case without a jury -- said he and his clerk had marched with the 40,000 protesters for four blocks, although they stopped before the demonstration reached the Supreme Court, where the nine defendants now before him had been arrested kneeling on the steps.

Hannon said he was exercising his First Amendment rights and that he was opposed to the court's ruling in Roe, according to accounts of those in the courtroom. Hannon declined to comment yesterday on his participation in the march or his failure to reveal his participation earlier.

"He does not talk with reporters," Ingram, his clerk, said.

"It was a surprise," John Goode Haring, one of three defense lawyers, said later. "It was the first time anyone had heard a judge say that from the bench."

The American Bar Association Code of Judicial Conduct, which is followed in the District, states that "a judge should disqualify himself in a proceeding in which his impartiality might reasonably be questioned, . . . should respect and comply with the law and conduct himself at all times in a manner that promotes public confidence in the integrity and the impartiality of the judiciary," and "should refrain from political activity inappropriate to his judicial office."

Cathaee J. Hudgins, executive secretary of the D.C. Commission on Judicial Disabilities and Tenure, which investigates complaints of improper conduct by Superior Court and D.C. Court of Appeals judges, said she could not remember a similar incident involving a judge.

Hudgins said she could not say whether Hannon's actions were improper. "That's something that we'd have to see a formal complaint and see all of the particulars on," she said.

Immediately after Hannon's disclosure, Assistant U.S. Attorney Lizabeth McKibben asked him to remove himself from the case, arguing that his participation in the march clouded his ability to rule impartially. The defendants are charged with violating the misdemeanor statute that prohibits demonstrations on the grounds of the Supreme Court.

But after a recess, McKibben, asked if she still wished Hannon to withdraw from the case, said, "At this point, the government would withdraw the motion."

The problem, according to those familiar with the case, was that Hannon had made the disclosure about his participation in the march after the first witness, Supreme Court Police Lt. Leo Jackson, had begun testifying. That triggered the constitutional protections against "double jeopardy" -- the general prohibition on trying someone twice for the same crime.

Had Hannon revealed his activities earlier, the government could have simply asked him to step aside. As it stood, prosecutors were in a double bind: They could either stick with a judge they knew was sympathetic to the cause of the defendants before him, or risk losing the case entirely.

"I don't know what we would have done, had we known" earlier that Hannon had marched against abortion, said Helen Bollwerk, deputy chief of the Misdemeanor Section. "In any event, the decision was made to withdraw" the motion for a new judge. "There could conceivably have been a situation of double jeopardy [and] ultimately it was decided we would go forward with the trial."

Hannon, 67, appointed to the bench by President Nixon in 1972 after serving for more than 10 years as chief of the Civil Division of the U.S. attorney's office, has earned a reputation as a conservative, crusty judge who brooks no nonsense from attorneys who appear before him. In 1973, he sentenced a public defender service lawyer who was inadvertently late returning from a recess to two days in jail or a $50 fine. The D.C. Court of Appeals later overturned the citation.

In 1983, Hannon overturned a jury award of $750,000 to a 12-year-old girl whose family contended she was born with birth defects because her mother took the morning sickness drug Bendectin.

At least one of the defense lawyers was clearly pleased with yesterday's development. After McKibben withdrew her motion for a new judge, Hannon asked defense lawyer J. Andrew Chopivsky whether he was "satisfied" with that outcome.

"That you're staying?" Chopivsky replied. "Oh, yes."