After 18 days of relentless assault on the conduct and character of D.C. Mayor Marion Barry, prosecutors retreated Friday for the first time from a position they had taken in open court. It was not the kind of retreat that strikes optimism in the heart of a defendant.

At issue was a laboratory analysis of hair samples taken from Barry on the night of his Jan. 18 arrest. Prosecutors, who called it "unequivocal" proof of the mayor's drug use in the six weeks preceding the Vista Hotel sting, have fought defense challenges to its reliability. But on Friday, Assistant U.S. Attorney Richard W. Roberts said the government would hold back the lab results, "to avoid an appeal in the event of conviction."

Those words represented a dramatic shift of purpose as the prosecution prepared to rest its case: from taking ground in the jury box to holding it in a court of appeals. For the first time since the trial began, prosecutors were showing as much concern about preserving a conviction as obtaining one.

"It means they think they're going to win, believe me," said an experienced former prosecutor with close ties to the government team. "You wouldn't give up good scientific stuff, even if it was disputed, unless you were very confident."

Sources close to U.S. Attorney Jay B. Stephens describe him as ebullient at the progress of the government's case. After sustaining months of criticism, Stephens is said to feel vindicated by the trial's methodical display of evidence against the mayor.

That evidence has run broader and deeper than anything publicly predicted before the trial. Where the indictment charged 10 episodes of cocaine possession, witnesses for the government testified to at least 150. Where the indictment charged three counts of perjury, the prosecution's case suggested many others.

More damaging to the mayor, though all but irrelevant to the formal case, was the transformation in the story line of the trial.

Boiled down to its essentials, the indictment alleged only that Barry possessed cocaine and lied about cocaine. Barry can be convicted of nothing more. But the evidence at trial suggested a multitude of sins, some of them more serious than those charged.

The 18 jurors and alternates -- and, through media reports, an international audience outside the courtroom -- heard Barry connected not only to cocaine but to opium and marijuana; not only to possession of drugs but to distribution of them; not only to perjury but to an organized coverup that hinted at obstruction of justice. They heard one woman sob from the witness stand that Barry sexually assaulted her, a second that he slapped her to the floor. As Effi Barry listened, still another woman testified she was the mayor's lover, and three more said he made sexual advances.

Prosecutors tried to tarnish Barry's legacy as mayor almost as much as his personal conduct. Logs displayed at the trial of telephone messages left for him at night and over weekends showed several times as many calls with alleged sex and drug partners as with government officials.

Two witnesses, Hazel Diane "Rasheeda" Moore and Carole Bland Jackson, testified that Barry rammed through the bureaucracy a contract for "Project Me," their summer youth program, because of his intimacy with Moore. Moore testified he canceled the contract after she refused a demand for oral sex.

"He told me . . . if I turn my back on him, I am turning my back on the program," she said.

The government used Moore to lay out the public corruption theme. In a bench conference June 28, Assistant U.S. Attorney Judith E. Retchin argued Moore should be allowed to testify -- ostensibly to explain her reasons for agreeing to bait the Vista sting -- "that Mr. Barry was out of control and that she was concerned about the effect cocaine was having on the city."

U.S. District Judge Thomas Penfield Jackson overruled an objection by the defense. When Retchin asked the question, Moore responded:

"What begins at the top trinkles down to the bottom, and it does affect the masses . . . . If the leader is corrupt or is not a body under the laws, it is going to affect the body of the people that he governs . . . . The mayor has admitted to me that he realized it was affecting him, his position as a public servant."

In that exchange, as in many others, the government was not making its case through the words of its attorneys. Roberts and Retchin have rarely used their questions, the way defense lawyer R. Kenneth Mundy and co-counsel Robert W. Mance have, to perform for the jury or suggest facts not in evidence. Roberts, who made an opening statement of considerable dramatic power, did it virtually without adjectives.

"The government in a case like this does not need to be showy," said William D. Pease, a former federal prosecutor. "It's not {Roberts and} Judy Retchin against Ken Mundy. It's the evidence against Ken Mundy."

Two prosecution exhibits, each growing day by day, summarize the burgeoning case against the mayor.

Government's Exhibit 2, titled "Locations," employs magnetic strips to list the places where witnesses have said Barry possessed cocaine. By Friday it named nine hotels, four boats, 18 private homes, two government offices and a private business.

Government's Exhibit 17 is a time line stretching for seven years. For each month in which a witness remembers seeing Barry with cocaine, prosecutors remove a white square, exposing a red one beneath.

It is either an oversight or a tantalizing hint of evidence to come that the 1990 calendar stops not at January, but February. There has been no evidence presented that the mayor used cocaine after his arrest. Prosecutors declined to say whether they will allege this in their rebuttal case, which follows any evidence by the defense.

The government's fear has always been what lawyers call a "nullification defense." Without saying so directly, Mundy might persuade the jurors -- or even one holdout among them -- to refuse to convict the mayor regardless of the evidence.

Nullification depends on an appeal to emotion. Prosecutors appeared to combat that appeal with a systematic effort to elicit unflattering facts.

Zenna Matthias testified that Barry watched a sexually explicit video and grabbed at her waist during their first meeting. Moore used the word "adultery" three times and "adulterous" once in describing her relationship with him. Hassan H. Mohammadi spoke of Barry's gambling, with more than $3,000 in borrowed chips, and reminded the jury that the mayor had been vacationing in California when snowstorms disabled the city in 1987.

Some of the best legal minds in the U.S. Attorney's Office helped find theories supporting introduction of other damaging evidence that usually would be excluded from a trial.

The most powerful tool was the charge of "conspiracy to possess cocaine," first made public in May but conceived by criminal section chief H. Marshall Jarrett long before Barry's arrest, knowledgeable sources said. The conspiracy idea relaxed the usual inhibition against presenting evidence that the defendant committed crimes for which he is not charged.

A conspiracy is an agreement between two or more people to break a law, provided that at least one of them commits an "overt act" in support of the agreement. In Barry's case, the alleged conspiracy consisted of obtaining cocaine between 1984 and 1990, and denying it.

By that standard, there are easily 10,000 cocaine conspirators each year in D.C. courts. But prosecutors rarely make the charge. In any case, it was tailor-made for Barry, since investigators had unearthed many more incidents of Barry drug use than Stephens wished to charge in his indictment.

The conspiracy charge allowed prosecutors to portray hundreds of episodes without having to prove them each beyond a reasonable doubt. In many cases they could not have done so: Moore and Mohammadi, for example, could not remember dates or other details of dozens of the drug possessions they alleged.

The conspiracy charge also helped portray the mayor as a hypocrite. Last week, prosecutors played a videotape of the mayor leading city residents in a chant of "down with dope." They said the chant was a denial and was part of the conspiracy.

Some damaging evidence was admitted on theories other than conspiracy. Prosecutors said much of the alleged sexual misconduct was mentioned because it was "inseparable" from the circumstances in which it took place, or because it showed a relationship between the witness and the defendant that would help jurors assess the witness's credibility.

A videotaped news clip of the mayor defending undercover drug buys was shown to the jury, according to prosecutors, to corroborate testimony by Charles Lewis and Moore that Barry was wary of surveillance.

One law enforcement official familiar with the case said it usually is not hard to "taint" someone accused of violent crime. But, the official said, "if you bring an otherwise educated and white-collar criminal into the courtroom, it's a double-edged sword to get down and dirty."

Early in the trial, as the pattern of uncharged allegations began to emerge, reporters approached Stephens in the courtroom. Charles Lewis had just finished testifying that Barry, fearing surveillance, twice took light bulbs from a Ramada Inn bathroom. Why, reporters asked Stephens, had he not charged the mayor with theft?

Stephens answered in deadpan. He meant it as a joke, but there was a grain of something serious in the reply.

"We didn't want to overreach," Stephens said.