A measure to give tenant groups or government agencies the right of first refusal when rental apartment buildings go up for sale to condominium developers was passed unanimously yesterday by the Montgomery County Council.

The bill is similar to legislation struck down by the Maryland Court of Appeals last year on grounds that it unfairly singled out condominium developers. Wording has now been expanded to cover sales for conversion to hotels, office buildings and cooperatives and for demolition.

The new measure gives certain tenant groups 180 days to buy a building put up for sale, providing they meet the owner's terms or offer the same terms that the owner has received from outside parties. If a tenant group does not make the purchase, the Montgomery County government and then the Housing Opportunities Commission, a public housing agency, have the right to buy the building under the same terms, according to the law.

Right of first refusal was devised as a protection for tenants faced with losing their rental homes due to the widespread condominium conversions of recent years. The bill also includes provisions for the landlord to pay tenants who do leave up to $750 compensation.

Other measures passed include a 4 percent tax on condominium sales to provide seed money for construction of new rental housing.