In a surprise turnaround, millionaire builder Dwight W. Mize agreed yesterday to abandon plans to buy and develop the McLean Gardens apartments, making way for the McLean tenants and their financial backers to purchase the 43-acre complex in upper Northwest Washington.

But the settlement agreement, presented to U.S. District Court Judge Louis Oberdorfer on the eve of a hotly disputed trial between Mize and the tenants over who has the right to buy the choice housing site, was protested immediately by the current owners of McLean Gardens, CBI Fairmac.

The dispute remained unresolved yesterday. Oberdorfer ordered all parties to return to court Tuesday for further proceedings.

Under the agreement, an 18-page document hammered out in allnight negotiating session by attorneys for Mize and the tenants, the tenants would buy out Mize's present contract to purchase the apartment complex from Fairmac by paying Mize $2,250,000 - but with several conditions.

If the tenants and their backers could not complete purchase negotiations with Fairmac and go to closing by Sept. 5, Mize would be paid an additional $267,000 a month until Dec. 5.

If the tenants and Fairmac fail to go to closing by Dec. 5, the tenants would have to step aside and allow Mize to reenter the scene and negotiate for the property unemcumbered by any tenents' claims.

The agreement represents a reverse in Mize's recent strategy. Just last week, he offered the remaining 164 tenants in the complex $14,000 each to move out and make way for his plans to turn their units into condominiums. His total offer was nearly the same amount the tenants are now agreeing to pay to Mize to abandon the project.

Mize said yesterday he decided to get out of the project because he had wearied of constant negotiating with the tenants and Fairmac and because constantly changing property laws in the District of Columbia make the city an impractical place to invest.

"If has been an unpleasant situation . . . only in D.C. do you have laws that change every time you blink your eyes," Mize said in reference to the city's recently reimposed condominium moratorium.

The moratorium, rent control and other land restrictions make property investments a frustrating business, he said.

"I wouldn't invest two cents to develop or building D.C. now," he said. " . . . Rent control is a forerunner of slums."

McLean Gardens, one of the few moderate income rental properties remaining in Upper Northwest along Wisconsin Avenue, has become a battlefield for tenants and would-be developers over the last several years.

Several developers have tried to buy the 43-acre plot of gently rolling land and turn the World-War-II-vintage gray stone apartment buildings there into condominiums, commercial structures or even a diplomatic enclave.

At every attempt, the tenants fought back and kept the complex largely intact.

In March 1978, however, Fairmac notified the tenants it planned to end the complex's use as a rental facility, and in May, Mize signed a contract to buy the place for $30 million and convert the units to $45,000 to $75,000 condominiums.

Tenants, organized under a vigorous residents association, objected, contending that under a city law that went into effect just before Mize signed his contract with Fairmac, the tenants were entitled to first right to buy the complex.

In September, Fairmac agreed to offer the tenants a chance to buy the project for $25 million. Three months later, the tenants, along with several financial backers, signed a contract and put down a $500,000 deposit.

The tenants' plan included development of moderately priced and luxury town houses and duplex apartments to be built on the site's plentiful vacant land.

Their contract, however, appeared to conflict with that of Mize, and last December the tenants association entered District Court to ask that Mize's contract be ruled invalid.

The trial on that issue before Judge Oberdorfer was scheduled to begin yesterday morning. Attorneys for Mize and the tenants, however, came into court with their last-minute settlement allowing the tenants to buy out Mize's contract for $2,250,000.

Attorneys for Fairmac immediately objected, reportedly because Fairmac was not a party to the agreement and its interests were not represented.

Repeated attempts to reach attorneys or business representatives of Fairmac for comment yesterday were unsuccessful.

Oberdorfer admitted the settlement agreement into the court record of the case and indicated he wants to study it further. He instructed the attorneys to return to court at 1:45 p.m. Tuesday.

"A key issue Tuesday," said one source involved in the case, "will be to what extent Fairmac has a right to object."

In an interview yesterday, Mize said constant negotiating and bickering over the McLean Gardens project has left him exhausted and he wants to return to his family in California.

"I'm a family man," he said. "I operate a family business . . . I love my very much. I haven't seen her much in the last 15 months. I've been spending three-fourths of my time traveling."

That is why "I wanted to bring this thing to a head [by selling his contract to the McLean tenants]...It's really more important than making a buck."

He said he has many other development projects in Texas, California and Nevada, "and I'd rather be doing other things than fighting Fairmac, the tenants and the D.C. government."