A Fairfax County judge ruled yesterday that Washington shopping mall magnate Theodore N. Lerner forfeited a $1.5 million deposit when he bowed out of an agreement to purchase 117 acres of the county's most valuable undeveloped land earlier this year.

The ruling was a victory for Lerner's longtime and now bitterly estranged partners, who may keep the deposit, but it left unresolved the fate of Tysons II, a wooded tract at the heart of Fairfax's downtown that has tempted and ensnared developers for the better part of a decade.

Lerner, who owns a quarter of the tract, agreed to purchase it from his partners, who own three-fourths of the land, for $35 million in a dramatic courtroom auction last summer. In January Lerner said that onerous demands by the Virginia highway department had nullified the agreement.

The case has involved some of the nation's biggest developers, represented by Fairfax County's most prominent zoning attorneys. Although Lerner and his lawyer, John T. (Til) Hazel, himself a major developer, lost a round yesterday, several people suggested that Lerner may welcome a delay as long as interest rates remain high. Hazel said Lerner would appeal the decision.

"It's a stalling game, and it's been a stalling game since 1964," said Homer Gudelsky, Lerner's primary partner in the Tysons Corner regional shopping mall and the undeveloped Tysons II. "I've got to live long enough just to beat the b------."

Lerner declined comment. Hazel said, however, that Lerner has good reason to delay the project because of the highway department demands. "Lerner is certainly not dumb enough to walk into a trap in Richmond where he might pay $25 million, plus the cost of the land," Hazel said.

Gudelsky, a 71-year-old Maryland developer, Lerner, 56, and H. Max Ammerman, a 78-year-old Washington attorney, developed Tysons Corner as Northern Virginia's first regional mall, and it has been a great success. But increasing traffic problems at Tysons Corner, where Rte. 123, Rte. 7 and the Capital Beltway come together, and intensifying disputes among the partners have precluded development of Tysons II, a tract owned by the same three men and their families across Rte. 123 from the mall.

Circuit Court Judge Richard J. Jamborsky said yesterday that Lerner may have demonstrated in a court hearing last week that the Virginia highway department "is difficult to deal with." The judge said, however, Lerner had not shown that its demands that Lerner pay up to an estimated $11 million in road improvements justified breaking the contract with his partners.

"It's conceivable that $35 million was perhaps too much to pay for the property," Jamborsky said, and that the highway department has increased development costs. "All of which goes to make it a bad bargain . . . But I don't believe that would justify the return of the $1.5 million" to Lerner.

"The unanswered question is that the demands of the highway department make this land impossible to develop," Hazel said. He called a number of highway officials to the stand last week, including longtime friend and former Virginia Highway Commissioner William B. Wrench, who supported Lerner's bid four years ago to develop the property as a second shopping mall.

Wrench urged the Fairfax Board of Supervisors to approve a controversial rezoning and in 1978 repeatedly urged state highway officials to move quickly in planning highways for the project, which was halted for economic reasons until last year. Wrench resigned his highway position last September.

Hazel said highway department demands escalated last November, when the department said Lerner would have to build an additional lane on Rte. 123 and contribute toward construction of an interchange between Rte. 123 and International Drive.

Lerner is not the only developer to have been discouraged by Tysons Corner traffic problems and by the highway department's reluctance to pay for necessary improvements. Gerald D. Hines Interests, the Texas developer who created Houston's massive Galleria mall, was interested in Tysons II, said knowledgeable officials, but was discouraged by the road problems.

Hines met with county officials last month and traveled to Richmond to talk with highway officials, discussing the possibility of building offices, stores and hotels on the site. His attorney in Washington, Robert Linowes, declined comment yesterday, but one knowledgeable official said the needed road improvements made the project unworkable, at the current land price.

That price is likely to go down from the $35 million Lerner agreed to pay when he outbid Boston developer Mortimer B. Zuckerman in the courtroom auction last summer, E. A. Prichard, the prominent zoning attorney representing Ammerman and Gudelsky, said yesterday. Both Hines and Zuckerman might look at Tysons II again if the court holds another auction, Prichard said.

"I felt last summer that they bid it up to a point beyond its real value," he said. "I think he Lerner has something of an emotional commitment as well as a financial interest."

Hazel and Prichard will meet in court again later this month to argue about what should happen next. Prichard's clients want to sell the land and want the judge to forbid Lerner from bidding this time