Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

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.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

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."

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.

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.