A California school district outside of San Francisco agreed to desegregate its schools on Friday, after a two-year state investigation found that the district had “knowingly and intentionally maintained and exacerbated” racial segregation and even established an intentionally segregated school.

Students in the district, Sausalito Marin City, are divided into two starkly different schools, according to the state Justice Department, which conducted the investigation: a thriving, racially and economically integrated charter school in the heavily white enclave of Sausalito, near the Golden Gate Bridge, and an overwhelmingly black, Hispanic and poor traditional public school about a mile away, in the more diverse community of Marin City.

The arrangement was no accident, Xavier Becerra, the California attorney general, said on Friday, but a deliberate scheme by school district officials to set up a separate and unequal system that would keep low-income children of color out of a white enclave.

As part of the new agreement, the district agreed to desegregate by the 2020-21 school year, and provide scholarships and counseling to students who had been hurt by the segregation.