Washington-based U.S. District Judge Colleen Kollar-Kotelly ruled in favor of the administration by refusing to block the commission from asking for the data. The decision was a loss for the Electronic Privacy Information Center (EPIC), a watchdog group, which filed a lawsuit challenging the commission's actions.
Studies have shown voter fraud is rare in U.S. elections.
Trump, who set up the commission by executive order on May 12, charged without evidence last year that millions voted unlawfully in the November presidential election.
He won the Electoral College, which tallies wins in states and determines the presidential winner. But he lost the popular vote to his Democratic opponent, Hillary Clinton.