The US Justice Department has announced charges against two Russian spies and two criminal hackers with the theft of 500 million Yahoo user accounts in 2014, marking the first US criminal cyber charges ever against Russian government officials.

The spies are members of the Russian Federal Security Service (FSB), and the two hackers were hired by the Russians. The FSB was linked by America's intelligence agencies to hacks of the Democratic Party and Hillary Clinton's campaign early this year, by Justice Department officials emphasised that the cases are not linked.

The FSB officers Dmitry Dokuchaev and Igor Sushchin "directed, facilitated, and paid" hackers Alexsey Belan and Karim Baratov for hacking into the computers of American companies providing email services, according to Acting Assistant Attorney General Mary McCord.

They were said to have targeted Yahoo accounts of both American and Russian cybersecurity, military and diplomatic personnel as well as employees of financial services and other businesses. They also hacked the emails of Russian journalists.

Belan has been one of the FBI's most wanted cyber criminals. Baratov has been taken into custody in Canada.

Both Dokuchaev and Sushchin "were acting in their capacity as FSB officials" during the hacks, McCord said. Some of the data stolen from Yahoo was then also used to compromise other accounts with Google and webmail providers.

The charges against the men include hacking, wire fraud, trade secrets theft and economic espionage.

Dokuchaev, worked in the FSB's Center for Information Security (CIS) and was detained by Russia in December 2016 along with his office's deputy chief on accusations of treason. According to Russian newspaper Kommersant they were accused of receiving money from foreign organisations.

The investigation of Russia's influence on the US election is an "ongoing and separate investigation," McCord said.