Sausalito, Calif., just north of San Francisco. (Michael Robinson Chavez/The Washington Post)

Just two taxpayer-funded schools serve the quaint town of Sausalito, Calif. There’s a charter school where a plurality of the students are white, and a traditional district school where almost no one is.

That’s no accident, according to California’s attorney general, who alleges the school district knowingly created and maintained a segregated school, and starved it of funding needed for basic necessities while funneling extra money to the charter school.

On Friday, the Sausalito Marin City School District agreed to a settlement that orders officials to unravel the segregation, compensate graduates who were harmed by it and build a more equitable system. If the district fails, the charter school might lose its Sausalito campus.

“Every child — no matter their stripe or stature — deserves equal access to a quality education,” California Attorney General Xavier Becerra said in a statement. “That’s what we say, what we believe, and what’s required under the law. But what we say isn’t always what we do. Certainly, it’s not what the Sausalito Marin City School District did when it chose to segregate its students.”

The settlement, filed in state court Friday, is a rare example of government-mandated school desegregation in recent years. It has been several decades since the state of California forced a district to make these sorts of changes, a Becerra spokeswoman said. Nationwide, most court-ordered desegregation plans have been lifted. The Supreme Court has barred school systems from considering race in student assignment plans, even when the goal is desegregation.

But the issue gained new prominence this summer among Democrats seeking their party’s nomination for president, after Sen. Kamala D. Harris (D-Calif.) challenged former vice president Joe Biden to explain his opposition to mandatory busing in the 1970s to integrate schools.

Research shows that attending diverse schools benefits children of all races. It finds children of color do better academically, and white students do no worse. It also found that all children are better prepared to live and work in a multicultural nation.

The two schools in the tiny Sausalito district north of San Francisco serve a total of just 525 students. Last year, only 119 of them went to the district-run school, called Bayside Martin Luther King Jr. Academy, and nearly eight in 10 were black or Latino.

Last year at the charter school, Willow Creek Academy, about half the students were white or Asian.

In the court settlement, the district promises to desegregate its system and improve offerings at the district-run school, with a goal of attracting more white and Asian students. If the district fails, it may be ordered to remove the charter school and reestablish an elementary school where it now sits.

The district also agreed to provide career counseling and create a scholarship program for past and current students potentially harmed by segregation.

At a press conference with the state attorney general to announce the agreement, Ida Green, president of the school district’s board of trustees, said the settlement was long overdue.

“It should not take the highest policing agency in California to ensure that we are taking care of the children,” she said. “Today’s settlement with the [attorney general’s office] enables the district to move forward with full transparency, lifting that veil of secrecy.”

All students in the district used to attend a single school in Sausalito, but in 2010, the district built a second school, now known as Bayside MLK, in the neighboring town of Marin City. The idea was to operate it as a middle school serving grades six to eight, with elementary grades remaining in Sausalito. (Students attend high school in a neighboring district.)

Instead, in 2012, the district consolidated all grades — from kindergarten through grade 8 — in the new school. It gave the building in Sausalito to Willow Creek Academy, the public charter school.

Before making that decision, the board of trustees, which oversees the district, was repeatedly warned by members of the community and others that the plan would create racial segregation. Critics of the plan cautioned that white people from Sausalito would not send their children to a school in Marin City dominated by children of color when they had the option of a charter school closer to home, the state of California said in its filing.

The board approved the plan anyway.

It went on to offer considerable financial support to Willow Creek, the charter school. Charter schools are privately run but publicly funded, and they traditionally are given a sum of money to educate each student they enroll. Willow Creek was given far more.

For example, the district does not charge Willow Creek rent or other facilities-related costs for the space provided for the 25 percent of its students who come from other districts. It also picks up the cost of special education at the school, according to a 2016 report by California’s Fiscal Crisis & Management Assistance Team, an independent state agency.

“The support the district provides to WCA [Willow Creek Academy] far exceeds anything contemplated under current law and regulations, as well as what is reasonable and fair based on common practice,” the report said.

It also said that key parts of the financial section of the memorandum of understanding between the school district and Willow Creek “are poorly crafted, leaving much to interpretation.” And separate financial formulas used to fund the school “are built on top of other formulas, creating conflicts with one another and in some cases diverting the same dollar twice.”

The report slams members of the school district’s board of trustees for their associations with the charter school, alleging that a majority of the board is “beholden” to the best interests of the charter school, not the district school. It said there was “a clearly biased financial arrangement that benefits WCA while harming the students of the district’s Bayside MLK school.”

Even as the board was generously funding Willow Creek, the district-operated Bayside school in Marin City was struggling. The settlement filed Friday describes the deficiencies: Bayside did not have a qualified math teacher, a full-time counselor or a prekindergarten program, but Willow Creek did.

The 2016 report concluded: “Although the district’s governing board made a decision to meet the Sausalito community’s needs through extraordinary support for WCA, it has yet to make a similar decision to invest in the students of Marin City.”

Now, the district is vowing to fix the problems. In the court settlement, it promises to form a “desegregation advisory group” within two months to make recommendations on reducing racial segregation. Given that the district operates only one school, the challenge will be attracting a more diverse student body by luring students away from the charter school, rather than changing boundaries or student assignment rules.

Within six months, the school system promises to develop a plan to improve academics, discipline policies, community and family engagement, and other matters.

If certain demographic targets are not met within five years, the district will be required to move children in kindergarten through 4th grade back to the Sausalito campus, where Willow Creek is located. If the charter school is still there, it would need to be relocated.

“This settlement represents a turning point and clear plan to support our healing from a collective community trauma that has its roots in systems and structures that are decades if not centuries old in Sausalito, and in Marin City, in our county, in our state and in our country,” school district superintendent Itoco Garcia said.