A Baltimore man pleaded guilty yesterday to second-degree rape -- to keep his 14-year-old victim from going to jail for refusing to testify against him.

The man, whose identity is being withheld to protect the victim, was charged with having sexual intercourse 25 to 30 times with his sister-in-law, now 14. The girl, who lives in Glen Burnie, was 9 years old when the sexual relations began, prosecutor Cynthia M. Ferris said.

But the victim, who says she loves the 25-year-old defendant, refused to testify against him during his trial in Anne Arundel County Circuit Court, prompting Judge Eugene M. Lerner to threaten the girl with jail for contempt of court.

Ms. Ferris and defense attorney David P. Henninger had already selected a jury and made opening statements. Ms. Ferris warned the jury that the middle school student might not cooperate.

"She's formed a misguided loyalty to him [the defendant]," Ms. Ferris said.

Despite warnings from the judge, the victim refused to answer questions while on the stand.

Judge Lerner sent the jury out of the courtroom before questioning the girl. "Do you want to go to jail, young lady?" he asked her.

"No, Your Honor, I don't."

"Well then, you'll answer the questions."

"No, Your Honor, I won't," she said.

The attorneys were flustered. Ms. Ferris said later that she had no case without the girl's testimony.

The girl's mother, wringing her hands, called across the courtroom, "You're going to go to jail for him?"

Judge Lerner drafted attorney Peter O'Neill into service, telling him to talk to the girl.

Relatives from both families darted into the hall. When they returned minutes later, Mr. Henninger said the defendant had agreed to plead guilty to spare the girl from jail.

The girl jumped from her seat, shouting "No!" and a string of obscenities.

Ms. Ferris said she would recommend a sentence of five years with all but two years suspended, and would drop a contempt charge against the girl in exchange for the guilty plea. The maximum penalty for second-degree rape is 20 years, she said.

Judge Lerner imposed the sentence, giving the defendant credit for time served since his arrest Jan. 29. He also imposed four years of supervised probation after the jail term and ordered the defendant not to have any contact with the girl until she is at least 16 years old, the legal age for sexual consent.

In addition, the judge ruled that the defendant would submit to psychological counseling.

The incidents, which led to charges in both Anne Arundel County and Baltimore City, occurred from about 1987 to last October, when the girl ran away from home, Ms. Ferris said. Several weeks after the girl was reported missing, police located her and she confided in them that her brother-in-law had repeatedly had sexual relations with her.

Mr. Henninger said his client was arrested after an investigation of several months. The man also was charged in Baltimore because the incidents allegedly took place at both the defendant's and the girl's residences.

The defendant is still married to the girl's sister and the couple has two children.

He is scheduled for trial in Baltimore June 29, Mr. Henninger said.

As the man was led out in chains past the girl's mother, she shouted, "I hate you!"