PHILADELPHIA—Department of Homeland Security Secretary Kirstjen Nielsen warned Saturday that Russia’s election interference amounted to a “direct attack on our democracy,” saying the indictment Friday of alleged Russian hackers shows such attacks will have consequences.

In a speech to a gathering of secretaries of state and election directors from around the country, Ms. Nielsen offered reassurances that U.S. elections wouldn’t be shaken by cyberattacks from foreign adversaries, while stressing the need for state and local officials to take the issue seriously.

“Any attempt to interfere in our elections—successful or unsuccessful—is a direct attack on our democracy and is unacceptable,” Ms. Nielsen said.

Her remarks came a day after special counsel Robert Mueller returned an indictment accusing 12 Russian intelligence operatives of hacking the computer systems of Democratic Party organizations during the 2016 presidential election.

The indictment showed that the U.S. “will not tolerate interference with our democratic processes, and that there will be consequences for foreign meddling,” Ms. Nielsen said.