Mayor Marion Barry vowed yesterday to put more group homes for the mentally retarded in all parts of the District, despite the intense opposition they have generated from residents throughout the city.

"We are going to put group homes in every neighborhood in our city," Barry told an annual meeting of the D.C. Association for Retarded Citizens. "I hope people like it, but if they don't like it, I'm sorry, we are going to do it anyway."

Residents in the past have indeed not liked it, and new group homes for the mentally retarded have led to angry confrontations between residents and city officials in neighborhood after neighborhood.

The neighbors generally claim they have not been informed in advance of the homes and express concerns about the effects the homes will have on property values and the safety of their children.

The city actually has little choice but to create the group homes, because it is under court order to place or keep mentally retarded persons in the least restrictive settings possible.

In 1978, U.S. District Court Judge John H. Pratt ordered the closing of Forest Haven, a District institution in an out-of-the-way location in Laurel that had been home to large numbers of mentally retarded persons, and ordered that 100 patients a year be placed back into the community.

Barry embraced the placement of Forest Haven residents in the city's neighborhoods yesterday and said he was proud of having increased the number of group homes to 100 from the four he said existed when he was elected in 1978.

"We modified our zoning laws" so that group homes could go into all residential areas in "every ward, every precinct," the mayor said.

There were 1,100 mentally retarded persons at Forest Haven in 1978, compared with 295 now, Barry said. At the end of this year, he said, the number will be down to 250.

Barry noted that his own neighborhood in Ward 7 was not exempt from getting a group home, which he said is around the corner from his house on Suitland Road.

"My own neighbors were opposed to it at first . . . . They raised holy hell about it," he said. "I have lost friends personally and politically over this."

The District government is trying to establish group homes not only for the mentally retarded but for a variety of other people as well, among them juveniles in trouble with the law and mentally ill persons being deinstitutionalized from St. Elizabeths Hospital.

So far, there are more than 500 group homes of different types in the District, and city officials are concerned about reaching the saturation point in many areas. There are restrictions on how close together such homes can be placed.

In some cases, opposition has died down quickly once the residents are placed in a neighborhood.

In one fashionable area of Cleveland Park, for example, neighbors opposed a group home being put in their area several years ago, but several of the opponents later testified at a City Council hearing that the residents of the home made good neighbors.