Mayor Marion Barry's decision this week to fire Anita B. Shelton, director of the D.C. Office of Human Rights, follows a long-running controversy over the way the former civil rights activist administered the agency.

Shelton, 48, a tall, strong-willed former social worker with strong ties to the liberal social causes of the 1960s, held her city post for nearly five years in the face of strong criticism of her management style and judgment in dealing with politically sensitive discrimination cases.

But in the end, she lost Barry's support primarily because of what some mayoral aides said was her inflexible, adversarial nature and the widespread view within D.C. government that the human rights office was a shambles.

"This extreme adversarial stance made it difficult to achieve policy goals," Herbert O. Reid Sr., legal counsel to the mayor, said yesterday.

"It wasn't that the mayor had objections to any conclusions she reached . . . But you can write rules and do things other than litigate and adjudicate to resolve disputes , although you may have to litigate as a final step. But that wasn't her style."

"We apologized for her throughout the 1982 campaign," said a Barry aide who asked not to be named. "We handled complaint after complaint about her office--not about the decisions it made but the lack of decisions. Employers who were accused of discriminating couldn't get a decision. And employes bringing the complaints couldn't get results."

Many agree that Shelton's relationship with the mayor began to cool in 1981, when she ordered the D.C. Fire Department to fill 60 of 70 available firefighting jobs with members of minority groups and to give minorities preference in all new hiring.

Shelton's approach to boosting the number of blacks and other minorities in the fire department angered members of the predominantly white D.C. Fire Fighters Association, who had been among Barry's earliest labor backers in 1978.

"She put the mayor in a sticky spot," explained one of Barry's aides.

Romeo Spaulding, president of the Progressive Firefighters, one of two mostly black firefighters' groups that accused the fire department of racial discrimination in recruiting and promoting firefighters, defended Shelton's performance and said her firing was "shocking."

"I think she has done an excellent job, and as far as what happened here, I think it had more to do with politics than anything else," Spaulding said. "I thought things in her office were moving along fairly well. . . . Whether or not the fire department case itself sparked the friction, I don't know. There had been some harsh critical comments."

Shelton could not be reached for comment yesterday. The mayor has declined to discuss Shelton's firing, other than to say through a spokesman that he was not satisfied with her performance.

Shelton, a 1959 graduate of the Howard University School of Social Work, worked for the Christ Child Settlement House, the National Council of Negro Women and the National Urban League before she was appointed director of the Office of Human Rights in 1979.

She inherited a massive backlog of unprocessed cases. Her critics contend that she compounded the problem.

A lawyer who once worked in the office said yesterday that Shelton "was in way over her head and didn't listen to those employes who know what they were talking about.

"Everybody felt there were serious management problems with the office," the lawyer added. "The most serious problem was just plain lack of qualified upper management."

Shelton's office, which handles highly technical complaints of discrimination in employment, housing, public accommodations and education, operated without licensed lawyers between November 1979 and February 1981, according to a source. During that period, a law student and a lawyer who hadn't yet passed the bar handled the bulk of the work.

The federal Merit Systems Protection Board charged in 1980 that Shelton fired three high-ranking employes and demoted three others out of what the board called personal animosity.