HARTFORD, Conn. — A judge on Wednesday ordered Connecticut officials to develop plans for a major overhaul of the state’s public education system within six months, saying a huge gap in test scores between students in rich and poor towns shows parts of the system are unconstitutional and irrational.

Superior Court Judge Thomas Moukawsher in Hartford ordered the state to submit proposed reforms to the court to revamp its formula for distributing education aid to cities and towns, develop a statewide high school graduation standard such as a test, make eighth-graders show they have acquired the skills to move on to high school and replace what he called an irrational and weak statewide system of teacher evaluation and compensation.

Moukawsher spent nearly three hours reading his decision in a courtroom filled with local officials, parents and other interested onlookers.

“Beyond a reasonable doubt, Connecticut is defaulting on its constitutional duty to provide adequate public school opportunities because it has no rational, substantial and verifiable plan to distribute money for education aid and school construction,” Moukawsher said.

The ruling came in an 11-year-old lawsuit filed against the state by the Connecticut Coalition for Justice in Education Funding, a nonprofit group that includes cities, towns, local boards of education, parent groups and public school students.

The coalition alleges the state isn’t providing adequate education funding to cities and towns and isn’t meeting its constitutional obligation to provide all students with adequate educations. It says vast differences in test results, graduation rates and other factors between rich and poor towns show the funding system isn’t fair.

In recent standardized testing, more than 70 percent of students in the state’s richest towns met third-grade reading goals, while nearly 70 percent of students in the least affluent towns did not. On high school tests, most children in the wealthiest towns scored advanced in math and nearly the same in reading, while one out of three students in poor districts didn’t reach basic levels in math and did only modestly better at reading.

The state must submit its proposed reforms in 180 days.

It wasn’t immediately clear if the state Attorney General’s Office will appeal the ruling, possibly to the state Supreme Court. A spokesman for the office said state officials were reviewing the decision.

“This decision by Judge Moukawsher is a game changer for our children,” Bridgeport Mayor Joseph P. Ganim said. “This ruling is a detailed, thorough indictment of how the state fails to provide an adequate education in Bridgeport and other poor school districts in Connecticut.”

The judge said the state’s Educational Cost Sharing formula, which was used for years to distribute education aid to municipalities, was never fully funded and was abandoned by the state in the 2013-2014 fiscal year. In its place, the state legislature has approved set dollar amounts for every town, a system he said lacked reason.

For example, Moukawsher said, the Democrat-controlled General Assembly and Democratic Gov. Dannel P. Malloy changed the 2016-2017 budget earlier this year because of a budget deficit and reduced education aid to the state’s poorest districts by more than $5 million. While officials also cut school aid significantly for some wealthy towns, they increased aid to comparatively wealthy towns by more than $5 million, the judge said.

Funding to Bridgeport schools, for example, was cut by more than $900,000 as the city’s school district faced a $15 million gap to maintain current services, Moukawsher said. Bridgeport is having to lay off school staff, increase class size and cut school bus service to nearly all high school students. Meanwhile, towns such as West Hartford, Glastonbury, Branford and Shelton received hundreds of thousands of dollars in aid increases.

“An approach that allows rich towns to raid money desperately needed by poor towns makes a mockery of the state’s constitutional duty to provide adequate educational opportunities to all students,” the judge said.

Malloy said in a statement that the state has invested hundreds of millions of dollars in education since he took office in 2011, with a large share directed at the neediest students. The state gives cities and towns about $2 billion a year in basic education aid and another $1 billion for school construction.

“We welcome the conversation this decision brings,” the governor said. “We know that to improve outcomes for all Connecticut students and to close persistent achievement gaps, we need to challenge the status quo and take bold action.”