A federal judge on Friday threw out the Trump administration's plan to check state voter lists against federal immigration records, a setback for its election efforts weeks before the midterms.

In a 78-page ruling, U.S. District Judge Sparkle Sooknanan in Washington wrote that the Justice Department "cannot run roughshod over longstanding laws that were carefully crafted to protect the rights of the American people," CBS News reported.

The department had asked every state for its full voter list, including private details like home addresses and Social Security numbers. It then ran names through a Homeland Security database called SAVE, which was built to check immigration status for people seeking benefits, and urged states to remove people it flagged.

The judge said the policy broke the Privacy Act and the law that governs how agencies make rules. She also said the database can be wrong. The ruling covers lists the department already has as well as ones it is still fighting for.

The case was brought by the voting group Common Cause and four U.S. citizens whose registrations were canceled. One, a Texas man, got a letter saying SAVE had flagged him as a noncitizen. His passport had expired, and by the time he renewed it, his registration was gone, Courthouse News reported. It was later restored.

"The challenged policy represents the federal government's attempt to decide who gets to vote," Sooknanan wrote. She added that the ruling "does not pave the way for ineligible voters to vote."

President Trump says more federal checks are needed to stop noncitizen voting, though most election experts say it is extremely rare. The Justice Department said it is reviewing the decision.

The short-term effect may be small. Federal law bars states from systematic voter-list removals within 90 days of a federal election.

What we know: The voter-list policy is struck down nationwide.
What we don't: Whether the Justice Department will appeal.