The McLean Gardens Residents Association, representing about 180 tenants at the Northwest Washington apartment complex who refused to give up in the face of what seemed almost impossible odds, signed a contract yesterday to purchase the project for $25 million.

"We're on the verge of ending eight years of fighting," tenant chairman Jack Koczela said last night. "I'm just extremely happy. My happiness is expressed in the faces of the people who live here when I tell them that we signed a contract today. We have every intention of seeing the contract through to fruition."

Ann M. Garfinkle, the association's attorney who also is representing six other tenant groups trying to buy their buildings, said the contarct signed yesterday probably represented the largest such deal made with a Washington residents association in terms of money and land.

"We surprised a lot of people," Garfinkle said.

The tenants' contract conflicts with one signed previously by the current owner, CBI Fairmac, with California builder Dwight W. Mize. The validity of the contracts may have to be determined in court.

Mize contracted last May to buy McLean Gardens, which for years has been one of the city's largest concentrations of moderately priced rental housing. Mize announced then that he planned to convert it to condominiums ranging in price from $45,000 to $75,000.

After learning about the new contract signed by the tenants, Mize said last night that he will contest their contract in court. Mize said he considers that the tenants have a plan for McLean Gardens that involves others as developers.

Concerning that and other legal matters, Mize said, "I will no doubt seek legal interpretation... I feel certain that my contract -- my rights -- would be acknowledged in any court of law."

The tenants now must obtain construction and permanent financing before settlement on the purchase. Neither Garfinkle nor Koczela said they could recall specifically how much time the contract allows them to do so, but Garfinkle said the limit is either February or March.

Fairmac attorney Eric Von Salzen confirmed yesterday that a $500,000 deposit was accepted from the residents but declined to release details about the contract.

One of the tenants' prominent financial backers is William P. McCulloch III, a lawyer who is on leave from the World Bank and who has renovated slum housing in Southeast Asia. McCulloch has said that some major national builders are very interested in the tenants' project and that the tenants are negotiating with several financial institutions, including the First National Bank of Chicago and the First National Bank of Maryland.

Last September, before Mize settled on his May contract, Fairmac offered the residents' association a chance to buy the property for $25 million.

The offer gave tenants 90 days, expiring yesterday, to make a $500,000 deposit and draw a contract with Fairmac. It came one day before tenants were to appear before the city's Rental Accommodations Office to charge that under city laws governing rental housing they should have been given first right of refusal to buy the complex.

Fairmac had sent tenants eviction notices in March, saying it wanted to end the 723-unit complex's rental use, and numerous other attempts have been made to force the tenants to move. At various times, owners of McLean Gardens planned conversion to condominiums, a $160 million complex of apartments and commercial buildings and a $150 million diplomatic enclave with apartments, shops, international boutiques, embassies and chanceries.

If they become owners of the complex, located on Wisconsin Avenue NW, several blocks northwest of Washington Cathedral, tenants plan to develop moderately priced and luxury townhouses and duplex apartments.

New housing is to be constructed on the 10 acres of vacant land at the site. The total number of housing units would be expanded to more than 1,300, according to plans. Some buildings would be seven-story condominiums, and some units would be priced as low as $35,000 for a one-bedroom unit, according to a spokesman.

Tenants plan to keep some of the complex as a moderately priced cooperative or as condominiums for existing tenants.

Koczela, the association chairman, said last week that individual tenants would not benefit from sales of the condominiums. Profits would be used to pay off their debts and loans, he said. The $500,000 deposit was raised with the help of loans from area banks and from other backers, he said.

The tenants struggle was symbolic for many city tenants of the fight to control buildings and stave off condominium conversions.

Four years ago, when buying condominiums was fairly new to many area residents, the city housing department approved the conversion of only 613 apartments, many of them in the Adams-Morgan area.

But the condominium conversion movement grew to such an extent that during the first six months of this year, more than 5,000 units in many different areas of the city were approved for conversion.

A city housing official said in an interview several months ago that actual conversions also have increased dramatically.

Mize recently signed a contract to purchase The Towers at Cathedral and New Mexico avenues NW and said he plans to convert the 613 apartments there to condominiums.

Mize noted that he has offered to sell part of McLean Gardens to its tenants for use as they wish and said he plans to continue working with them.