A key portion of Montgomery County's law designed to protect renters from losing their apartments when owners convert them to condominiums was struck down yesterday by Maryland's highest court.

As a result of the ruling by the Court of Appeals, thousands of tenants whose apartments will be converted to condominium units may be forced to relocate -- something that is increasingly difficult to do within the county.

The law governing condominium conversions was enacted by the County Council in July 1979 because the accelerating pace of conversions was sharply diminishing Montgomery's supply of rental housing. Since last January, 2,355 apartment units have been converted to condominiums in Montgomery, and tenants purchased most of them.

County officials received the news of the court decision with dismay, while landlords were elated.

County official Charles Maier called it "the most serious setback we've had in looking out for the good of tenants in Montgomery County."

James Cromwell, attorney for landlords who brought the suit, said the county law" imposed a burden on a condominium that was not on any other type of property."

The provision that was struck down gave tenants the right to form groups to purchase their buildings when owners initiated condominium conversion. The so-called first-refusal law gave such groups 120 days to meet the owner's terms before a building's units could be offered for sale to others.

Tenants who have already been given notice that their buildings will be converted to condominiums and who have formed tenant organizations will still have the right to purchase their buildings, according to County Attorney Paul McGuckian.

The law will not apply to future conversions, and county officials are considered likely to ask the Maryland General Assembly, which convens in January, to enact statewide legislation that would reinstate the measure in Montgomery.

The court, in a 5-to-2 decision, held that the county law violated a state law mandating that all zoning and building statutes be "uniformly applicable" to all types of buildings.

Judge Rita Davidson, dissenting, argued that the condominium conversion law was not a zoning or building law within the meaning of the state statute.

The suit contesting the law was brought by landlords of five buildings, including the Georgian Woods apartments and the Westchester West apartments, both in Silver Spring, and the Randolph Square apartments in Rockville. None of the five buildings has been converted to condominiums yet.

The court also struck down the county law requiring landlords to pay $750 in relocation expenses to each tenant forces to move because of condominium conversion.

The District of Columbia also has a first-right-of-refusal law governing condominium conversions; that law is unaffected by yesterday's decision in Maryland.