A California appeals court handed teacher unions a big victory Thursday by reversing a trial judge's ruling that found tenure deprived students of a good education.

The 2nd District Court of Appeal said the plaintiffs failed to show tenure and other provisions of the education code were unconstitutional.

"The court's job is merely to determine whether the statutes are constitutional, not if they are 'a good idea,'" presiding Justice Roger Boren wrote.

A Los Angeles Superior Court judge had ruled two years ago that five provisions of the state education code -- including policies allowing teachers to receive tenure within two years and be dismissed during layoffs based on seniority -- were unconstitutional because they deprived some of the state's 6.2 million students of a quality education by keeping more senior, but less effective, teachers on the job.

In a ruling that threatened to shake up public schools across the state, Judge Rolf Treu had said the evidence "shocks the conscience."

But in reversing that ruling, the appellate court said state law wasn't to blame for inequities.

"Although the statutes may lead to the hiring and retention of more ineffective teachers than a hypothetical alternative system would, the statutes do not address the assignment of teachers," Boren wrote. "Instead, administrators -- not the statutes -- ultimately determine where teachers within a district are assigned to teach."

Vergara v. California had pitted the state and its largest teacher unions against a group of students who asked the judge to consider laws regarding teacher tenure, dismissal and seniority consideration for layoffs. A Silicon Valley-based group called Students Matter brought the lawsuit on behalf of nine students, contending the targeted laws hinder the removal of ineffective teachers and disproportionately hurt low-income and minority students.

The case was closely watched and highlighted tensions between teacher unions, school leaders, lawmakers and well-funded education reform groups over whether policies like tenure and last-in-first-out keep ineffective teachers in the classroom, particularly in already low-performing schools.

The lawsuit was filed by nine public school students, including Beatriz Vergara, and backed by Students Matter, a nonprofit group founded by Silicon Valley entrepreneur David Welch.

Attorneys for the state and its teachers unions had argued that the case was flawed and should be overturned because no evidence was presented showing the disputed statutes are the cause of educational inequalities, saying the suit was never about helping students.

A similar lawsuit was filed in New York after the Vergara decision, contending that state's teacher tenure and layoffs by seniority laws deprive students of a sound, basic education as guaranteed under the state constitution. Lawyers for New York's teachers union have asked for the case to be dismissed.

Attorney Theodore Boutrous Jr. says in a statement Thursday that the 2nd District Court of Appeal's ruling is a "temporary setback" and expects to appeal the decision to the California Supreme Court. He argues that teacher tenure amounts to "egregious constitutional violations" of students.

Check back for updates on this breaking news story.