Washington shopping center magnate Theodore N. Lerner settled a bitter dispute with his partners yesterday by agreeing to a $28 million price for their disputed Tysons II property minutes before it was to be auctioned off in a Fairfax County courtroom.

Lerner, who owns a 25 percent interest in the 117-acre wooded tract across from his Tysons Corner Mall, agreed to pay $21 million in cash by July 22 to his estranged partners, Homer Gudelsky and Max Ammerman, for their share.

After closing the deal, Lerner, who has developed malls at Tysons, White Flint and Landover, said he plans to develop Tysons II in partnership with Homart Development Co., a subsidiary of Sears, Roebuck and Co. The joint venture will build offices, hotels and stores on the coveted site during the next 10 years, Lerner and his lawyer said.

Lerner's last-minute settlement with his two longtime partners, with whom he is barely on speaking terms, appeared to end a long dispute over who would develop one of the largest undeveloped tracts along the Capital Beltway. The settlement also disappointed a crowd of more than 100 lawyers, real estate agents and civic leaders who had packed a small courtroom in Fairfax City to watch bidding that would have begun at $25 million and climbed in $100,000 increments. "I came to see a battle," one unhappy broker said as he walked out.

Participants said the high-rolling negotiations and the final arguments in a judge's chamber were as dramatic behind the scenes as the public auction would have been. Lerner's lawyer, John T. Hazel Jr., said the partners and their attorneys had been fencing "24 hours a day since this time last week" and did not sign their agreement until 1:30 p.m., 30 minutes before the auction. "Poker games never end until the last hand," Hazel said.

The agreement between Lerner and his partners, Ammerman and Gudelsky, shut out a group of Minneapolis investors who had traveled to Fairfax to bid for Tysons II, described by its owners in advertisements as "probably the most valuable property on the East Coast."

The Minnesota investors were said to have exploded angrily in the chambers of Fairfax Circuit Court Judge Richard J. Jamborsky when he told them they could not bid. They later declined to discuss their reactions publicly.

Lerner had agreed once before to purchase the property from his partners. In an auction in 1981 he bid $35 million for the wooded land, which is located across Route 123 from the mall he developed with Ammerman and Gudelsky.

That deal was never consummated and the partners are still fighting in court over the $1.5 million deposit Lerner put down then. His refusal to pay the $35 million exacerbated tensions among the partners that clearly had not healed with yesterday's agreement.

"I just wonder if Lerner will welch out of this one like he welched out of the last one," Gudelsky said after the deal was closed.

"Homer has to get his licks in," Hazel responded. Lerner has said he did not close on the earlier $35 million deal because the Virginia highway department unexpectedly demanded costly road improvements before allowing development there. Hazel said yesterday Lerner and his new partner will have to resolve that issue with state officials.

Although the price of Tysons II fell $7 million in two years, real estate experts said that did not reflect a drop in true value. Lawyer E.A. Prichard, who represented Ammerman and Gudelsky, had said from the start that Lerner had bid too high two years ago to keep a rival developer, Boston's Mortimer B. Zuckerman, from buying the site.

The partners never met face to face during the final negotiations, sitting instead in their separate law firms' offices that face each other across a parking lot in Fairfax City. Lerner, alone among the partners, did not appear in court, but left Hazel's office beaming after the deal was settled and announced he was off to play racquetball.

When Hazel and Prichard announced their agreement in court on behalf of their clients, Judge Jamborsky said he had no choice but to cancel the auction, despite the presence of the Minneapolis investors. "The parties are in agreement as to what they think is a fair settlement, so the court would certainly approve it," the judge said.

Tysons II landed in court when its owners, who together had developed Northern Virginia's first regional shopping mall across the highway, could not agree what to build on the site. Lerner wanted to build another mall, while his partners were anxious to steer clear of anything that would compete with the existing shopping center.

In sometimes heated negotiations this week, Ammerman and Gudelsky tried to insist that Lerner promise not to build another regional mall. Lerner prevailed in resisting that demand, but Hazel said yesterday there is "absolutely no likelihood of a repetition of Tysons I."

One of the most interested observers in the courtroom yesterday was Fairfax tax assessor Sam Patteson. Fairfax increased the assessment on the Tysons II property to $29.2 million after Lerner agreed to the $35 million price. When that deal fell through, the Tysons II partners challenged the assessment in court, and that case is expected to be affected by the lower price agreed to yesterday.