In a landmark decision with national ramifications, a Los Angeles judge ruled Tuesday that California laws governing teacher tenure, firing and layoffs violate students’ constitutional right to education equality — a stunning victory for the Silicon Valley nonprofit that brought the lawsuit on behalf of nine students, including three from the Bay Area.

The long-awaited ruling by Los Angeles Superior Court Judge Rolf M. Treu found that the evidence of how poor teachers affect students “shocks the conscience” and that “there is also no dispute that there are a significant number of grossly ineffective teachers currently active in California classrooms.” He noted that the current laws protect bad teachers, harm students and disproportionately affect poor and minority pupils.

Treu ordered the state to stop enforcing tenure, dismissal and layoff laws but stayed his orders pending possible appeals by the state and California’s two major teachers unions. The decision was a huge defeat for the powerful teachers union and sent a clear signal to legislators to begin rewriting those laws to make it easier to fire poorly performing teachers, to delay or change tenure rules and to rework layoff criteria so that newly hired teachers aren’t always the first to lose their jobs.

The advocates in the case, which had been closely watched across the country, hailed the ruling as historic.

“This is a monumental day for California’s public education system,” said lead co-counsel Theodore J. Boutros Jr., who also successfully argued the case that struck down California’s ban on same-sex marriage. “This decision is going to reverberate powerfully across California and across the nation.”

Unions, however, denounced the decision in the case known as Vergara vs. California.

“The millionaires behind this case have successfully diverted attention from the real problems of public education,” said Fred Glass of the California Federation of Teachers.

CFT President Joshua Pechthalt called the suit “fundamentally anti-public education, scapegoating teachers for problems originating in underfunding, poverty and economic inequality.”

The lawsuit was brought by Students Matter, a group funded largely by entrepreneur Dave Welch of Atherton, who was ecstatic about the outcome and disagreed with unions’ accusations that the suit was an attack on public schools.

“I believe in public education. It is a key cornerstone and pillar of democracy,” said Welch, a father of three who co-founded optical telecommunications system firm Infinera and has been active in school reform.

Treu’s ruling agreed with the plaintiffs on all challenges to the current laws:

Granting tenure, essentially permanent employment, to teachers after about 18 months on the job unfairly disadvantages teachers and students, the judge wrote, noting that California is one of only five states granting tenure after two years or less.

Dismissal laws that effectively require from two to 10 years to get rid of a teacher and force districts to spend $50,000 to $450,000 or more to fire grossly ineffective teachers amount to “uber due process” that results in school districts allowing such teachers to continue in the classroom. Treu noted that 1 percent to 3 percent of California’s 275,000 active teachers are considered grossly ineffective, or up to 8,250 teachers.