Mohammad Hosein Musa Kazemi, 24, and Sajjad Kashian, 27, conducted a cyber campaign "to intimidate and influence American voters, and otherwise undermine voter confidence and sow discord," the department said Thursday.
In parallel, the US Treasury announced sanctions on the two men and three others who ran the cybersecurity company they worked for, Emennet Pasargad.
The Treasury said the company was formerly known as Net Peygard Samavat, which was hit with sanctions in 2019, and the Justice Department gave its former name as Eeleyanet Gostar.
Iran hit back in a statement, saying "such accusations addressed by the US government, who itself has a long history of meddling in other countries' affairs in different shapes and forms, are baseless".
Such actions, foreign ministry spokesman Saeed Khatibzadeh said, aim to "deceive (American) public opinion."
Kazemi and Kashian allegedly obtained confidential voter information and sent menacing emails, pushing out false information to influence both Democratic and Republican voters, and attempting to hack into state voting-related websites, the department said.
In one case, they sent out mass emails claiming to be from the far-right Proud Boys militia group that threatened people to change political parties.
In another, they created and disseminated a video that purportedly showed a person hacking state voter websites and creating fraudulent ballots.
The indictment did not tie the two directly to the Iranian government, but noted that the company had done work for the government.
In 2019 the Treasury said Net Peygard Samavat worked with the Islamic Revolutionary Guard Corps.
And in March 2021 US intelligence released a report that said the Iranian government was behind a multi-pronged influence campaign aimed at hurting former president Donald Trump's reelection chances.
Kazemi and Kashian are charged in federal court in New York with conspiracy to commit computer fraud and abuse for trying to intimidate voters, voter intimidation, and transmission of interstate threats.
Kazemi was also charged with computer hacking and computer fraud.
The penalties for the various charges run from one to 10 years in prison.