Minnesota will receive a $6.5 million federal grant in mid-May to upgrade and modernize its voter registration system. The funding was included in the $1.3 trillion spending bill signed March 23 by President Donald Trump.

It incorporated a $385 million proposal by Sen. Amy Klobuchar, D-Minn., and Sen. James Lankford, R-Okla., for improvements in states’ election cybersecurity.

Every state will receive at least $3 million with adjustments for population, Klobuchar said at a news conference Thursday in Minneapolis.

Minnesota was among 21 states where voter databases were targeted by entities linked to the Russian government in 2016. The state’s system was not hacked, but those in Arizona and Illinois were.

Securing Minnesota’s database is essential, Secretary of State Steve Simon said. It has been in use since 2004 and contains driver’s license and Social Security information.

Appearing Thursday with Klobuchar, he called cyberattacks the top threat to election integrity. “It could be Russia, China or the guy next door,” he said. Simon said the federal grant could be used for upgrades instead of $1.4 million in state funds proposed by Gov. Mark Dayton earlier in March, as part of a four-year budget plan for election cybersecurity.

In addition to state grants, the federal spending bill included $300 million in counterintelligence funding for the FBI to fight Russian hacking.

The next step in ensuring secure and fair elections, Klobuchar said, is to curtail the sale of individual data online and to ensure that the purchasers of online campaign and issue advertising are public.

The Senate Judiciary Committee, on which she serves, has asked Facebook CEO Mark Zuckerberg and top Google and Twitter executives to testify at an April 10 hearing on data privacy. Research firm Cambridge Analytica improperly gained access to the personal data of more than 50 million Facebook users.

Klobuchar said that she has long advocated regulations — “rules of the road” — for social media companies.

“We have one big abuse that’s occurring right now, and we need to protect people’s private data and also to protect them when it comes to elections,” she said.