An organic farmer in Potomac who started an international campaign to save his farm from Montgomery County officials and from the local school board has scored a temporary victory, reaching a settlement with officials to keep it until August.

Nick Maravell was scheduled to go to Montgomery County Circuit Court on Thursday, seeking to stay on school system-owned land he has tended for 31 years. His lease expired in March, when school officials leased the land to the county for soccer fields. He was permitted to stay there until the end of the year.

The court hearing was seen as a last-ditch effort by Maravell to save the farm before being forced to leave. He had appealed to the state school board, a separate case that is still pending.

In the Circuit Court case, Maravell asked a judge for an injunction to stay on the land and alleged that the school board violated open-meetings laws when making the decision, which outraged many local community activists and neighbors. A series of petitions to protect the farm has gathered 50,000 signatures, including thousands from Montgomery and some from as far away as Germany.

But Maravell said Wednesday that he and county officials have reached a preliminary settlement. He will drop the court case in exchange for staying at the farm until Aug. 15. He said the county could further extend his stay until the end of next year.

Rockville-based lawyer Jim Parsons, who represents Maravell, said the farmer has agreed to a separate settlement with the school board. Parsons declined further comment on the school board settlement, citing a confidentiality agreement.

School board member Patricia O’Neill (Bethesda-Chevy Chase) said attorneys are still working out the details. She said she was relieved, because she had never before been subpoenaed in her 13 years as board member.

“I think everyone was on pins and needles,” she said.

In the state case, Maravell has asked the state board to decide whether public land can be used for public-private partnerships, such as maintaining soccer fields.

The dispute shows how education, opportunity and proper land use can come into conflict in Montgomery, where open space is scarce and school enrollments are high. Soccer fields are in high demand; 14,000 young suburbanites join youth soccer leagues.

School officials have said athletic fields are in line with their mission. Maravell has said he wanted to use the land as an education farm and give students the chance to visit and learn about how food is grown.

The settlement is expected to please county officials, who have been dealing with the negative publicity caused by Maravell and his supporters.

For instance, they rallied in Rockville last month and marched up to the second-floor office of County Executive Isiah Leggett (D). Before cameras and reporters, they handed a petition with 23,000 signatures to Joy Nurmi, one of Leggett’s top aides.

Leggett has said he would give Maravell other land to farm — an offer that the farmer has rebuffed.