FBI director James Comey, standing behind US Attorney General Loretta Lynch, apparently ignored warnings from the justice department about going public / Alex Wong/Getty Images

The attacks cost their victims tens of millions of dollars, according to the US government

The US government has charged seven Iranian hackers over a series of cyber attacks, in the latest example of it pursuing foreign nations for hacking.

The government says that the hackers were involved in attacks on banks and a small dam near New York City. The attacks happened between 2011 and 2013, and the government claims that they came from Iranian companies.

The hacks were undertaken “with the sole purpose of undermining the targeted companies and damaging the online operation of America's free market”, said US attorney general Loretta Lynch.

Federal law enforcement officials announced the charges at a news conference in Washington, during which they said the attackers were “experienced computer hackers” and that the attacks served as a “wake-up call”.

The case stems in part from a 2013 cyber intrusion in which hackers targeted the Bowman Avenue Dam, a small flood-control structure in Rye Brook, about 20 miles (32 kilometers) north of New York City.

It's the latest instance of the Obama administration publicly blaming foreign nations for damaging cyberbreaches.

The Justice Department in May 2014 indicted five Chinese military officials suspected of hacking into several major American companies and stealing trade secrets.

Additional reporting by Associated Press