WASHINGTON -- A US federal judge on Monday struck down a Trump administration database containing US citizens' private information, ruling it unlawful after several states used it to mistakenly purge eligible citizens from voter rolls.

"The federal government has knowingly trampled on the privacy rights of American citizens in a manner that threatens the sacred right to vote. This Court cannot stand idly by while that happens," Judge Sparkle Sooknanan from the US District Court for the District of Columbia wrote in a ruling.

Federal agencies were scrambling to comply with an executive order aimed at reshaping federal elections, so they "haphazardly combined and repurposed the private information of millions of Americans, including citizenship data that they knew to be unreliable," Sooknanan said.

"Since then, states have partnered with the federal government to access the database and are actively removing United States citizens from voter rolls based on inaccurate information," she continued.

"This case implicates two fundamental rights that protect Americans from government overreach: the right to privacy and the right to vote," according to the US district judge.