Eight or more civilians died in the custody of British troops in the weeks after the invasion of Iraq, despite frequent warnings by the army's most senior legal adviser there about unlawful treatment of detainees, an inquiry has heard.

In devastating evidence to an official inquiry, Lieutenant Colonel Nicholas Mercer described the way Iraqi detainees were intimidated and hooded by British soldiers as "repulsive". He said that 10 days after the invasion in March 2003 he saw 20 or 30 detainees lined up with sandbags on their heads.

He was shocked, he said, adding that it was "a bit like seeing pictures of Guantánamo Bay for the first time".

Mercer said he had had a "massive row" with the commander of the Queens Dragoon Guards about the army's legal obligations under the Geneva conventions and the European Convention on Human Rights. He had walked out of a meeting between British officials and the International Committee of the Red Cross after being told by a "political adviser" to keep his mouth shut, he added.

Mercer's repeated protests about the unlawful treatment of Iraqis in British custody was so unwelcome within the Ministry of Defence that his boss, Martin Hemming, head of its legal service, threatened to report him to the Law Society, he said.

Mercer, who is still serving, was giving evidence into the death of Baha Mousa, a Basra hotel worker who died in British custody in September 2003. This was months after Mercer had persistently warned senior army officers — including General Robin Brims, commander of British troops in southern Iraq — that detainees were being subjected to unlawful treatment.

He revealed that he and Brims later refused to sign statements pre-prepared by Hemming as evidence to the Commons human rights committee.

He said the abuse of Iraqi prisoners might have been prevented if a British judge had been appointed to oversee the handling of detainees, a proposal that he said was blocked by Lord Goldsmith, the attorney general.

Goldsmith, who has said he never authorised the use of five banned techniques, including hooding, may be asked to give evidence to the inquiry with the former defence secretary Geoff Hoon, and former armed forces minister, Adam Ingram.

In his evidence, Mercer described how in May 2003, two months after first issuing his warnings, military police investigators told him about two deaths in custody. They added that they thought there were "five or six more deaths that required investigation".

Speaking later outside the inquiry, Phil Shiner of Public Interest Lawyers, which represents Iraqi detainees, said there were 47 "unresolved cases" involving the mistreatment of civilians by British troops. "There are so many cases, that is why we need a single inquiry [to cover them all]", he said.

Mercer recalled seeing one prisoner, Faisal Sadoon, held in "appalling conditions" in a container "with a barbed wire door in 40 degrees-plus of heat". He was told of prisoners appearing bruised and hooded at detention centres. He recalled seeing "a generator running outside the interrogation tent, which seemed to me to create a culture of intimidation and possibly with the aim of muffling any noise".

He warned that "in no circumstances should [detainees'] faces be covered as this might impair breathing" "I felt I was banging my head against a brick wall. We found ourselves in a constant legal battle," he told the inquiry.

He regarded hooding, banned in 1972, as repulsive. "It amounts to violence and intimidation and it degrades the individual so I don't like it in any circumstance," he said.

He said he felt vindicated when the Red Cross began to express concern in May 2003. British soldiers were handed cards before the invasion saying that civilians should be treated "humanely". But there was no training in interrogation techniques, Mercer said.

His warnings, and those of the Red Cross, reached ministers and top military commanders in London. But hooding was not banned until after Mousa's death more than six months later, the inquiry heard.

"The issue of prisoners had very low priority and was treated more as an inconvenience than an obligation under international law," Mercer said in a written statement to the inquiry. It was partly a question of resources and lack of planning, he said.

But he added that it was also about "proper education, training, and the moral compass". He said there was a "classic dilemma" in the army. "You're in the command structure and there's always pressure to do one thing, when legally you may believe something else".

An MoD spokesman said: "All deaths in British custody in Iraq have been thoroughly investigated. Having committed to a public inquiry, it would be wrong to comment upon any evidence presented to it."

He said the ministry will have an opportunity to respond to the report written by the chairman, Sir William Gage, at the end of proceedings.