Maryland's highest court yesterday overturned a controversial lower court ruling that had threatened to revolutionize the state's system of financing public schools and dramatically cut education funding in affluent areas such as Montgomery County.

In a 5-to-1 decision, the state Court of Appeals ruled that Maryland's current formula for public school funding is constitutional and that the court does not have ultimate authority to change it. The decision ended four years of contentious court battles between Maryland's richest and poorest school districts. Future decisions about the financing of local schools will now be left to the General Assembly.

Yesterday's decision knocks down a ruling by Judge David Ross of the Baltimore Supreme Bench that said the state constitution requires each of Maryland's 24 school districts to spend essentially the same amount of money per pupil, regardless of the districts' varying capacities to raise tax money to finance their schools. Such rulings were made recently in two states: Wyoming and West Virginia.

Under the present Maryland system, local school districts are funded by a combination of state aid and local tax revenues. Wealthier jurisdictions, such as Montgomery, are able to spend more money per pupil than poorer areas because their residents can pay higher taxes.

The Maryland court decision was the latest in a series nationwide involving the constitutional obligations states have in financing local public schools. In the last year, courts in Colorado, Georgia and New York have issued rulings similar to yesterday's decision in Maryland.

The U.S. Supreme Court has not become directly involved in cases of state financing of public schools since 1973, when it ruled in a Texas case known as "Rodriguez" that education is not mentioned in the U.S. Consitution and is therefore not a fundamental constitutional right.

Since then, courts in 20 states have wrestled with the issue, which was borne in activist legal circles during the War on Poverty and the civil rights movement in the 1960s.

Although there is no clear pattern in the decisions over the last few years, education experts said yesterday that Maryland's decision may reflect a changing political climate and the financial crunch the states are feeling in the 1980s.

Long-awaited in education and political circles, the 98-page decision is a major victory for Montgomery County, which has the highest level of per-pupil spending in the state. County officials had worried that Montgomery would have to limit or curtail the amount it spends per pupil each year--now more than $4,000--if the 1981 lower court decision had been upheld.

"We're very pleased that this has been resolved," said Montgomery County Executive Charles Gilchrist. "The potential fiscal impact would have been devastating to us and to the whole state, not to mention to public education."

The current state funding formula, devised by former Lt. Gov. Blair Lee III and Del. Lucille Maurer (D-Montgomery), attempts to equalize levels of per-pupil spending by using an index to distribute state funds that takes into consideration disparities in local wealth. The formula also requires a minimum level of spending that is the same for each jurisdiction.

Ross' ruling two years ago was the result of a suit filed in 1979 by the state's four poorest school districts: Baltimore City, and the counties of Somerset, Caroline and St. Mary's. These districts charged that, even with the Lee-Maurer funding formula, students in poorer jurisdictions were discriminated against because they still did not have access to the same quality of education as students in richer jurisdictions.

But the high court's majority opinion yesterday said this system is constitutional and that "there is no discriminatory purpose in Maryland's school financing system."

Judge Harry Cole of Baltimore was the lone dissenter, saying that the court's decision "places its imprimatur on an educational system which thwarts the full growth and development of a large segment of the school population."

In Baltimore, School Board President David C. Daneker called the decision "disastrous."

"We didn't expect them to close the door so tightly," he said.

Montgomery spent $1.3 million in legal fees on the case, known as "Somerset." County officials could not say specifically what the financial impact of the case would have been if the lower court decision had been upheld. But they gave ballpark figures ranging from $36 million to $80 million annually in lost state aid.

"The Ross decision was one of the harshest decisions in the country," said Maurer. "Today's decision recognizes that there is some leeway in local choices on education funding , over and above the state's responsibilities."