The federal government on Friday told election officials in 21 states that hackers targeted their systems last year, although in most cases the systems were not breached.

The government told The Associated Press last year that more than 20 states were targeted by hackers believed to be Russian agents before the 2016 elections. But for many states, the calls Friday from the Department of Homeland Security were the first official confirmation of whether their states were on the list.

The AP contacted every state election office on Friday. While not all of them responded immediately, those that said they were targeted were Alabama, Arizona, Colorado, Connecticut, Illinois, Iowa, Maryland, Minnesota, Ohio, Oklahoma, Pennsylvania, Virginia, Washington and Wisconsin.

Get Breaking News Delivered to Your Inbox

The government did not say who was behind the hacking attempts or provide details about what had been sought. But election officials in three states said Friday the attempts could be linked to Russia.

The Wisconsin Election Commission, for example, said the state's systems were targeted by "Russian government cyber actors."

Federal officials said that in most of the 21 states, the targeting was preparatory activity such as scanning computer systems. The targets included voter registration systems but not vote tallying software. Officials said there were some attempts to compromise networks but most were unsuccessful.

Only Illinois reported that hackers had succeeded in breaching its voter systems.

Colorado said the hacking wasn't quite a breach.

"It's really reconnaissance by a bad guy to try and figure out how we would break into your computer," said Trevor Timmons, a spokesman for the Colorado secretary of state's office. "It's not an attack. I wouldn't call it a probe. It's not a breach, it's not a penetration."

Sen. Mark Warner of Virginia, the senior Democrat on the Intelligence Committee, on Friday said it's unacceptable that the federal government took almost a year to notify states that their elections systems were targeted.

He said he's relieved the Department of Homeland Security is finally informing top elections officials in all 21 affected states "that Russian hackers tried to breach their systems in the run up to the 2016 election."

Warner said Homeland Security needs to notify state and local governments in real time of attempts to attack voting systems.

The disclosure to the states comes as a special counsel probes whether there was any coordination during the 2016 presidential campaign between Russia and associates of Donald Trump.

Mr. Trump, a Republican who defeated Democrat Hillary Clinton in the presidential election, has called the Russia story a hoax. He says Russian President Vladimir Putin "vehemently denied" the conclusions of American intelligence agencies.