A judge on Monday threw out a lawsuit against New York that claimed the state was shortchanging students in eight small city school districts and denying their constitutional right to a “sound basic education.”

While calling the students’ performance “undeniably inadequate,” state Supreme Court Justice Kimberly O’Connor said the plaintiffs hadn’t proved the state has not met its obligation to them.

The state’s largest teachers union called the decision “a blow to some of New York’s most vulnerable students.”

The lawsuit was filed in 2008 on behalf of students in Jamestown, Kingston, Mount Vernon, Newburgh, Niagara Falls, Port Jervis, Poughkeepsie and Utica, cities challenged by high rates of poverty, students with disabilities and English language learners.

The lawsuit accused the state of reneging on funding promises made after a Court of Appeals ruling in 2007 required the state to increase funding for New York City schools. After the ruling in the Campaign for Fiscal Equity lawsuit, the state reformed its statewide funding formula, but it hasn’t fully funded the new system while facing budget shortfalls.

During an eight-week trial this year, administrators from the small city districts described shortages of teachers, technology and supplies, which they said hurt students and graduation rates.

Monday’s ruling said the state could adjust funding levels for school districts based on fluctuations in its fiscal condition and still deliver on its obligation to ensure students have access to an adequate education. It added that the state has been addressing issues raised by school districts with each state budget and other reforms to academic standards and teacher evaluations.

O’Connor wrote that the performances of many of the students were unacceptable and “the educators, administrators, state actors and other employees of the school districts have a responsibility to see the reforms through to the end and improve the results for their students.”

“However,” the judge wrote, “the action that is required is not in the form of a specific dollar amount, but is instead a blend of funding, oversight and proper allocation of resources by the districts.”

Democratic Gov. Andrew Cuomo’s office declined to comment.

The Alliance for Quality Education, an advocacy group, said the decision would be appealed. It said the court had failed to thoroughly examine the facts.