A federal judge on Friday struck down as unconstitutional a Virginia law requiring people to state their race when applying for a marriage license.

“The Commonwealth of Virginia is naturally rich in its greatest traditions,” Judge Rossie D. Alston Jr. wrote in his opinion in the U.S. District Court for the Eastern District of Virginia. “But like other institutions, the stain of past mistakes, misgivings and discredited legislative mandates must always survive the scrutiny of our nation’s most important institution . . . The Constitution of the United States of America.”

The law, Alston found, violates the 14th Amendment right to due process. It is one of his first opinions; he was sworn in as a federal judge in August.

“We’re very pleased, of course,” plaintiffs’ attorney Victor M. Glasberg said. “The only unfortunate part is that it took a United States district judge to strike a Jim Crow provision that the state of Virginia insisted on defending in court.”

Three couples challenged the racial requirement last month, saying they had tried and failed to obtain marriage licenses without identifying by race.

Virginia Attorney General Mark Herring (D) quickly issued new guidance and a new marriage application form to clerks across the state, saying they should allow anyone to decline to answer the race question. At a court hearing last week, a lawyer for Herring’s office argued that the issue was now resolved until at least 2022, when a new attorney general will take his place.

“Had they brought this concern to officials, it could have been resolved without a lawsuit,” Virginia Solicitor General Toby J. Heytens said in court.

But the couples argued, and Alston agreed, that their concerns remained valid because the law requiring a racial designation was still on the books.

“Herring provided a construction of the statute that is expressly at odds with its plain meaning,” Alston wrote.

He also disputed the contention that there is no “straight line” between a 1924 state law prohibiting interracial marriage and the requirement to choose a race when getting married. On the contrary, in his order he agreed with Glasberg that the law reflected a racist and segregationist past embodied in the first state registrar of vital statistics, a white supremacist named Walter Plecker.

“When asked by this Court at oral argument whether there was any state interest in this racial data, Defendants conceded there was not,” he wrote. “The statutory scheme is a vestige of the nation’s and of Virginia’s history of codified racialization.”

Michael K. Kelly, a spokesman for the Virginia Office of the Attorney General, said in a statement the ruling was “consistent with AG Herring’s recent memo to the State Registrar noting that ‘any statute requiring a governmental official to deny a marriage license to an applicant who declines to provide information about his or her race would raise serious constitutional questions.’ ”