The D.C. City Council voted yesterday to prohibit foreign embassies from locating their office buildings in the wealthy neighborhoods flanking embassy row on Massachusetts Avenue and 16th Street NW.

The action appears to end a simmering two-year-old dispute that saw the city caught between the opposition of some of its most influential and wealthy citizens and pressure by the State Department to permit overcrowded embassies to locate chanceries in the residential areas.

Residents of the areas most likely to be affected, whose homes sell for $350,000 and up, have long argued that chanceries would clog their quiet treelined streets with traffic and cause other disruptions best confined to those locations currently occupied by the embassies.

"They bring in business activities and increase the traffic," said Samuel Scrivener, president of the Sheridan-Kalorama Neighborhood Council. "We're delighted to have ambassadors occupy buildings [in the neighborhoods] but we don't want office buildings."

The bill banning the chanceries was introduced in January by council members David A. Clarke (D-Ward 1) and Polly Shackleton (D-Ward 3) who represent the affected areas.

"We've been trying to get this bill for a couple of years to give some protection to the residential neighborhoods from the intrusion of these office buildings, because that's all chanceries are," Shackleton said.

The bill was prompted by a D.C. Zoning Commission decision a new special zone for chanceries along embassy row from Dupont Circle to 34th Street NW, and along 16th Street NW.

The Zoning Commission was responding to a recommendation by the National Capital Planning Commission to create the new zone. Two foreign governments, Saudia Arabia and Bangladesh, subsequently asked for permission to convert two existing buildings in the area to chanceries.

Saudi Arabia's application was approved by zoning officials before the bill was passed and is not affected by the vote. The application by Bangladesh was rejected.

The State Department, which had pressed for the new zoning, had no comment yesterday. In the past, it had strongly opposed the bill.

The council also passed yesterday a bill under which welfare recipients will be able to choose the funeral home they want to handle arrangements for burial of family members. Currently the W.W. Chambers Co. performs all burial services for the poor under a $272,655 contract with the city.

In fiscal 1978 Chambers performed 480 such burials. Its current basic fee is $585 for an adult burial, with a somewhat lower rate for children.

Under the new bill the funeral home performing the service would be paid $750 for a complete adult funeral service including the burial plot. The payment would rise in future years at the same rate as the federal Consumer Price Index.

Council member Nadine Winter (D-Ward 6), who cosponsored the bill with Clarke, said it was needed because the city's present system "does not provide the humane treatment of the poor at death," according to the council report accompanying the legislation.

Chambers, a white/owned firm, has been criticized for alleged insensitivity in handling the funerals, which mostly involve black families.

In other action, the council voted to require the city government to install smoke detectors in all its halfway homes, D.C. General Hospital, the D.C. jail, Lorton Reformatory and the city's home for the aged by Jan. 1, 1980, six months earlier than required under current law.

The bill also required privatly owned nursing homes and residential- custodial homes to install the detectors before the present June 1981 deadline if the homes change ownership before that date. Currently there is no provision for the detectors with a change in ownership.

All three bill now go to Mayor Marion Barry for his signature.