WikiLeaks founder Julian Assange has been charged in the United States with receiving and publishing thousands of classified documents linked to the wars in Iraq and Afghanistan.

The US Justice Department has indicted the 47-year-old, who is currently jailed in Britain, on 18 counts that relate to his “alleged role in one of the largest compromises of classified information in the history of the United States”, it said.

He is accused of working with former US army intelligence analyst Chelsea Manning in “unlawfully obtaining and disclosing classified documents related to the national defence”, a statement said.

The Justice Department said that by publishing unredacted versions of the leaked files, Assange put “named human sources at a grave and imminent risk”.

After a federal grand jury returned the indictment on Thursday, WikiLeaks swiftly issued a tweet describing the move as “madness”.

“It is the end of national security journalism and the first amendment,” it said.

Manning handed over databases containing roughly 90,000 Afghanistan war-related significant activity reports and 400,000 Iraq war-related significant activities reports, the Justice Department said.

There were also 800 Guantanamo Bay detainee assessment briefs and 250,000 US Department of State cables, it added.

Assange was dramatically dragged from the Ecuadorian embassy in Knightsbridge, central London, last month, some seven years after he sought political asylum after the documents were published.

He was then jailed for 50 weeks for a bail breach and is fighting against extradition to the US.

US authorities allege the whistleblower conspired with Manning, 31, “with reason to believe that the information was to be used to the injury of the United States or the advantage of a foreign nation”.

Assange published the documents on WikiLeaks with unredacted names of sources who gave information to US forces in Iraq and Afghanistan.

“These human sources included local Afghans and Iraqis, journalists, religious leaders, human rights advocates, and political dissidents from repressive regimes,” the Justice Department said.

“According to the superseding indictment, Assange’s actions risked serious harm to United States national security to the benefit of our adversaries and put the unredacted named human sources at a grave and imminent risk of serious physical harm and/or arbitrary detention.”

It added: “Many of these documents were classified at the Secret level, meaning that their unauthorised disclosure could cause serious damage to United States national security.”

Classified rules of engagement files for the Iraq war were also handed over by Manning, US officials said, and Assange is said to have agreed to hack into secure government networks.

The Justice Department said: “Assange actively encouraged Manning to provide more information and agreed to crack a password hash stored on US Department of Defence computers connected to the Secret Internet Protocol Network (SIPRNet), a United States government network used for classified documents and communications.

“Assange is also charged with conspiracy to commit computer intrusion for agreeing to crack that password hash.”

He faces a maximum of 10 years in prison for each count except conspiracy to commit computer intrusion, which is punishable by five years.

WikiLeaks editor-in-chief Kristinn Hrafnsson said in a tweet: “I find no satisfaction in saying ‘I told you so’ to those who for 9 years have scorned us for warning this moment would come.

“I care for journalism. If you share my feeling you take a stand NOW. Either you are a worthless coward or you defend Assange, WikiLeaks and Journalism.”