A Circuit Court judge has declared a private Loudoun County composting operation illegal, saying farmer Peter Knop needs a permit for his experimental efforts to break down stumps and other woody waste into organic fertilizer.

But Judge Thomas D. Horne handed Knop a partial victory by finding that his operation meets the county zoning law, opening a door for possible government sanctioning of the composting activity.

Knop collects branches, stumps and even whole trees cleared by developers, spreading the materials in massive rows on part of his 1,200-acre Ticonderoga Farms west of Dulles International Airport. By covering the rows with fungi and vines and keeping them moist, he hopes to turn the woody waste into compost that will enrich the soil on which he grows Christmas trees and nursery stock.

In a ruling late Friday, Horne said the operation does not meet the definition of recycling under laws controlling solid waste and therefore cannot continue until it has a disposal permit. However, he overturned a county government finding that Knop's activities are improper on land zoned for agricultural purposes, saying that no fire hazard has been proved and that heavy truck traffic off the site is legally irrelevant.

Knop and the county and state governments have been locked in a complicated legal battle over the operation for a year. Loudoun officials say trucks hauling debris to the farm have torn up roads, adding that Knop's financial success could encourage other farmers to set up illegal stump dumps.

Knop says his process is a new technology not covered by existing regulations and that he is willing to accept strict rules created for it. In July, Horne recessed a hearing in the case so that he could make a personal inspection of the Ticonderoga operation.

Yesterday, Loudoun Engineering Director Terrance Wharton termed the court ruling on Knop's business "a mixed bag . . . . We'll work with him" to see if regulations can be drawn up, Wharton said. "The rules are undefined at this point."

Although Knop says he will not stop accepting woody waste until a formal order is issued, he lauded Horne's opinion and said he got "90 percent" of what he wanted.

"We are applying for a permit immediately," Knop said. "We're now coming hat in hand, saying, 'Let's draw up regulations for a new industry.' "

State law will force all localities to recycle 10 percent of their solid waste by 1991 and 25 percent by 1995. Yard waste accounts for 18 percent of the material pouring into landfills, the Environmental Protection Agency says, and Knop says his process can help governments exceed recycling goals.

State and county ordinances cover solid waste disposal in Virginia, and the judge's opinion deals primarily with county laws. A state suit trying to shut down Knop's composting work is pending, as is Knop's federal suit alleging that officials have violated his civil rights.

Knop, who recently was appointed to the Virginia Forestry Board, also has had to shut down a composting facility in western Montgomery County. Ted Graham, director of the county Department of Environmental Protection, said Montgomery officials are "trying to sort out the legal and policy issues" before deciding if Knop can resume work at a site near Gaithersburg.

Virginia state Sen. Charles L. Waddell (D-Loudoun) said "the county and state must take their heads out of the sand" and set up a strictly regulated permit process for wood composting. Otherwise, a court challenge of Loudoun's solid waste laws could result in numerous unregulated stump dumps, Waddell said.