The district attorney of Philadelphia, Larry Krasner, has filed a lawsuit seeking to stop Elon Musk and his pro-Trump political action committee (or "PAC") giving away $1 million each day to a random registered voter in a US swing state.
He described the action as an "illegal lottery" and also said it might interfere with the integrity of the elections.
Philadelphia is in Pennsylvania, one of the more hotly contested swing states, which Donald Trump won in 2016 and Joe Biden won in 2020.
Krasner is himself a Democratic party politician who has described himself as a "progressive prosecutor."
The US Justice Department also sent a letter to Musk's "America PAC" last week warning that the daily giveaways could violate federal law, which prohibits paying people to register to vote.
Musk has become a prominent supporter of Trump during the election campaign, setting up the America PAC to fundraise and reportedly donating millions of his own fortune to it.
He was also in Pennsylvania at a Trump rally earlier in October.