Tesla CEO Musk has already given away $US16 million ($A24 million) to registered swing state voters who qualified for the sweepstakes by signing his political petition and said the final winner will be announced on election day on Tuesday.
At a hearing in Philadelphia on Monday, Judge Angelo Foglietta rejected Philadelphia District Attorney Larry Krasner's bid to block the giveaways.
Krasner alleged the payouts amounted to an illegal lottery with hazily defined rules.
Since October 19, Musk and his political action committee America PAC have been giving a $US1 million cheque every day to a voter who has signed his petition supporting free speech and gun rights.
Musk's offer is limited to registered voters in the seven states expected to decide the election - Arizona, Georgia, Michigan, Nevada, North Carolina, Pennsylvania and Wisconsin.
Musk became an outspoken Trump supporter this year and has promoted the former president on his X social media platform.
He has given nearly $US120 million to America PAC to promote its voter mobilisation and registration efforts, according to federal disclosures.
Krasner, a champion of progressive causes, called the program an illegal lottery that violates state consumer protection laws.
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, but federal prosecutors have not taken any public action.
Last week, Musk and America PAC sought to move the case to federal court, which temporarily prevented a state court judge ruling on Krasner's request for an order blocking the giveaways.
A federal judge swiftly sent the case back to state court, setting up Monday's hearing.