Pennsylvania Judge Angelo Foglietta's decision came after a surprising day of testimony in Philadelphia state court in which Musk's aides acknowledged hand-picking the winners of the contest based on who would be the best spokespeople for his super PAC's agenda, despite the billionaire's assertion that they would be chosen randomly.
Tesla CEO Musk has already given away $US16 million ($A24 million) to registered swing state voters who qualified for the giveaway by signing his political petition.
His group, America PAC, announced a winner from Arizona on Monday and said the final winner, from Michigan, would be announced on election day on Tuesday.
America PAC launched the contest on October 19.
Philadelphia prosecutor Larry Krasner sued to block the America PAC contest in Pennsylvania. (AP PHOTO)
It is open to registered voters in seven key battleground states - Arizona, Georgia, Michigan, Nevada, North Carolina, Pennsylvania and Wisconsin - who sign a petition pledging to support free speech and gun rights.
Philadelphia District Attorney Larry Krasner, a Democrat, on October 28 sued to block the contest in Pennsylvania, alleging the payouts amounted to an illegal lottery with hazily defined rules.
Foglietta denied Krasner's bid in a brief written order on Monday and said he would lay out his reasoning later.
Musk became an outspoken Trump supporter this year and has promoted the former president on his X social media platform.
He has so far given nearly $US120 million to America PAC to promote its voter mobilisation and registration efforts, according to federal disclosures.
Philadelphia is the largest city in Pennsylvania, one of seven battleground states likely to determine the outcome of the race between Trump, a Republican, and Harris, the Democratic candidate.
Whoever wins the state will receive its 19 electoral votes out of a total of 270 needed to win.
The giveaway falls in a grey area of election law, and legal experts are divided on whether Musk could be violating federal laws against paying people to register to vote.
The US Department of Justice has warned America PAC the giveaway could violate federal law, according to media reports, but federal prosecutors have not taken any public action.
The Trump campaign is broadly reliant on outside groups for canvassing voters, meaning the super PAC founded by Musk, the world's richest man, plays an outsized role in what is expected to be a razor-thin election.