The expected release from the D.C. Jail today of convicted drug dealer Karen K. Johnson signals the end of a controversial investigation in which federal prosecutors tried to prove that Mayor Marion Barry lied when he told a grand jury he had not obtained cocaine from Johnson.

Federal prosecutors have decided not to seek charges against Barry, concluding a nearly two-year investigation of drug use by D.C. government employes and others in which Barry's name surfaced in a secretly tape-recorded conversation of Johnson. The mayor's legal counsel acknowledged that Barry had a personal relationship with Johnson, a former low-level city worker, but the mayor has steadfastly denied that he ever bought drugs from her or used cocaine.

Barry aides and District politicians said yesterday that the failure to bring charges against Barry in the drug investigation has enabled him to maintain his formidable political base and position as the most powerful figure in District politics as he prepares to seek a third term next year.

U.S. Attorney Joseph E. diGenova is still vigorously pursuing several investigations into alleged wrongdoing in the city government -- including the Bates Street housing project and activities of former top Barry aide Ivanhoe Donaldson -- that could prove to be embarrassing to the Barry administration. However, the Johnson investigation was the only case in which specific allegations were made against Barry.

"I think the mayor will survive it all," said D.C. City Council member John A. Wilson (D-Ward 2), who unsuccessfully challenged Barry in the 1982 Democratic primary. "I think he has tremendous resilience. If there is a way to survive it, he will."

Current and former Barry aides said yesterday that Barry's supporters have discounted questions raised about the mayor's personal life style and integrity as an attempt by the media and the Republican-controlled Justice Department to discredit a prominent black public official.

They also said that the Barry administration's accomplishments in getting the budget under control and improving the delivery of city services have strengthened his hand and made it far more difficult for anyone to challenge him.

"This mayor has made the city move," said longtime Barry aide Courtland V. Cox. "By objective standards people may have some disagreement here and there on specifics but on the whole people have said he has been a good mayor."

Several black politicians said the black community is skeptical of diGenova's motives and many believe the mayor will remain untouched by the investigations.

"I think people are pretty satisfied with the thrust of city government," said William Lucy, a top national black labor union official active in city politics. "I don't think any of these things have affected Barry's political fortunes or future."

A veteran D.C. Democratic Party activist, who asked not to be quoted by name, said, "There's always been a hint of scandal with Marion, but the question is, 'How has that impacted on the government? If our taxes were being raised, if everyone were falling through potholes, that would translate into a political liability, but that's not the case. As for the investigations, I don't see anyone who can exploit it."

At its height last summer, the drug investigation touched off a stormy political battle, pitting Barry and his staunchest political supporters against diGenova, an aggressive prosecutor who has launched an unprecedented series of investigations into alleged corruption involving city officials and former Barry aides. The director of the city's cable television commission, Antonio Ruiz, resigned after he was linked to Johnson's drug activities in her indictment a year ago.

Barry responded to media reports of the investigation into his ties to Johnson with public accusations that diGenova's office was attempting to destroy him with selective leaks to the press, which he called, "a leak a week." At a rally for Barry at the Shiloh Baptist Church Family Life Center last August, the mayor compared the drug investigation to bygone efforts by whites to "lynch" blacks. "I'm not going to be lynched," Barry vowed.

At the center of this controversy was Karen Johnson, a former Barry campaign worker and employe of the D.C. Office of Energy. An investigation of Johnson's drug dealings took on larger implications when federal agents secretly recorded her telling a boyfriend that she had sold cocaine to Barry on numerous occasions.

Last July, Johnson was sentenced to four months in a federal minimum security facility in Southwest Washington after she pleaded guilty to cocaine sale and possession charges. She began serving the sentence on Aug. 6. Three days later she was held in contempt of court and transferred to the D.C. Jail after she refused to answer questions before the grand jury that was seeking further evidence in its drug probe.

She has remained quietly at the jail ever since.

Johnson's refusal to testify dealt a serious blow to the federal investigation, but also triggered a wide-ranging effort by prosecutors to come up with additional witnesses to corroborate the allegations concerning Barry, according to sources familiar with the case.

At one point, four U.S. Drug Enforcement Administration agents were assigned to assist prosecutors who also expanded their inquiries into areas that went beyond the specifics of the Johnson case. But sources said the efforts failed to turn up credible evidence to substantiate allegations against Barry.

Johnson, who initially was confined to the jail's infirmary and later transferred to a cell in the woman's wing, has spent much of her time reading newspapers and novels and lately has been tutoring other jail inmates, according to a D.C. Department of Corrections official.

"She's still just as she was," said the corrections official. "She hasn't cracked a bit." Johnson's contempt sentence is due to end at the same time as the official term of the grand jury, which expires today.

Johnson is then expected to be returned to the federal minimum security corrections center at 2912 Langston Place SE, to serve the remainder of her drug sentence. Officials said she will be required to have an outside job. Life at the center, which is run by Hope Village Inc., a nonprofit group under contract to the federal government, is not as restricted as the jail.

One of the investigations still pending involves allegations concerning former deputy mayor Donaldson's handling of about $30,000 in checks that he issued while he headed the city's Department of Employment Services.

On Tuesday, Chesapeake & Potomac Telephone Co. executive Delano Lewis, who was finance chairman of Barry's 1982 reelection campaign, said the grand jury probing Donaldson asked him about an $1,800 campaign expense check made out to a longtime Donaldson friend. Donaldson directed Barry's two successful campaigns for mayor and held several key posts in government.

"It's obvious this is going to be going on for a while," said a former Barry aide.