Moments after a District jury acquitted Robert Anderson last week of charges that he murdered his father and stabbed his brother, Anderson's attorneys told him he was a free man. But before Anderson could leave the courthouse, the prosecuting attorney made a startling request: Commit Anderson to a mental institution because he was mentally ill and a danger to the brother who testified against him.

The request, coming so soon after the acquittal, sparked protests from Anderson's lawyers who claimed the U.S. attorney's office was trying to "accomplish what the criminal proceedings had not."

Yesterday, after three days of hearings on a request described as unprecedented, D.C. Superior Court Judge Ricardo M. Urbina ordered continued commitment for Anderson at St. Elizabeths Hospital.

The judge said that although the decision was a "very, very close one," medical testimony had persuaded him that there was a "slight probability" that the 37-year-old District man was mentally ill and likely to be a danger to himself and others.

Anderson's lawyers did not comment on the ruling, but during the hearings they argued that disappointed prosecutors were attempting to retry their case through the civil commitment proceedings. Prosecutors countered that Anderson's paranoia was so great that he was more likely than not to attack those he believed had persecuted him.

"The government has in effect done what is done in the Soviet Union . . . ," said Anderson's lawyer Harry Fulton, chief of the Public Defender Service's mental health division. "It is using psychiatry to hold people it cannot otherwise hold."

Anderson had been examined at St. Elizabeths for nine months before trial. He had been found competent to stand trial but not to waive the insanity defense. If he had been convicted another trial would have been held to decide if he was not guilty because of insanity.

Although Urbina had warned the lawyers that he did not want a retrial of the murder case, testimony during the three days often centered on the 1983 homicide. At one point yesterday, prosecutor G. William Currier displayed the butcher knife that allegedly had been used to kill Anderson's father while the key government medical witness testified he "believed Anderson stabbed his brother and killed" his father.

The government's medical experts said Anderson's continued denial of his involvement in the crime and other assaults described by the family and police supported a diagnosis of mental illness.

But defense lawyer Fulton said that according to the government's argument, "If a person denies his guilt, as they are entitled to do under the law, that is mental illness."

Anderson told the judge yesterday, "I am not insane."

Jurors contacted after the verdict said they acquitted Anderson because the government's case rested on the testimony of "one brother against another" and they believed Anderson. The jury found discrepancies in the government's case, and its initial vote was 9 to 3 for acquittal, jurors said.

One juror said she found illogical the government's version of the crime, particularly details about how Anderson had fallen asleep after the crime and had carried a long butcher knife awkwardly in his pants without injuring himself. "Someone would have to be really insane . . . . It just didn't make sense," the juror said.