Al-Qaeda has said it carried out two mass jailbreaks in Iraq, which freed hundreds of prisoners including senior leaders of the Islamist militant group.

In an online statement, al-Qaeda said Sunday's attack was the final one in a campaign aimed at freeing inmates.

At least 20 security guards died when gunmen stormed the Abu Ghraib and Taji jails near Baghdad.

Abu Ghraib gained global notoriety in 2004 when images were released showing US guards abusing Iraqi detainees.

Iraqi officials had previously tortured regime opponents in Abu Ghraib during Saddam Hussein's rule.

Comment: Oh but nothing near the scale and depth of depravity reached by the U.S. governors of the jail...

On Tuesday, an al-Qaeda affiliate calling itself the Islamic State of Iraq and the Levant said it carried out the attacks on the prisons.

The group, which was formed of al-Qaeda groups in Iraq and Syria, said it had spent "months planning" the attacks on Abu Ghraib to the west of the capital and Taji to the north.

The group also claimed some 500 militants were among the hundreds of prisoners who had escaped.

'Under control'

Iraqi authorities initially denied any prisoners had escaped in the assaults, but later acknowledged "some" prisoners escaped.

The Iraqi interior ministry said in a statement on Tuesday that the gunmen had received help from some of the prison guards.

Fighting raged for several hours after the jails came under attack on Sunday night.

Gunmen fired mortar rounds at the prisons, and then used car bombs at the entrances.

The situation was eventually brought back under control on Monday morning, with the use of military helicopters.

Justice ministry spokesman Wissam al-Firaiji earlier said the attackers, whom he called terrorists, had been well-armed.

"The attack against Taji jail alone was carried out by nine suicide bombers and three car bombs driven by suicide bombers," he told reporters.

"The attackers also lobbed more than 100 mortar shells," he said, adding that the inmates were "under control" again.

The British government, which pulled combat troops out of Iraq in 2009, condemned the attacks.

"The United Kingdom supports the Iraqi government in its efforts to uphold the rule of law and apprehend those inmates that escaped," said Foreign Office minister Alistair Burt.