Nine Iraqis allegedly abused by British troops were thought to be linked to the killing of six Royal Military Police three months before, a court has heard.
The six Red Caps were killed by a mob in June 2003
Seven soldiers are standing trial on charges relating to the alleged abuse of civilian detainees in Basra, southern Iraq, in September 2003.
Prosecutor Julian Bevan QC said their suspected involvement in the killings of the Red Caps fuelled hostility.
One soldier admits inhumane treatment. Six others have denied abuse charges.
One of the detainees, Baha Mousa, 26, died in custody in Basra in 2003 while being held by members of the Queen's Lancashire Regiment (QLR), now the Duke of Lancaster's Regiment.
The six Red Caps were gunned down by a mob in the town of Al Majar Al Kabir in June 2003.
Mr Bevan told the court martial at Bulford Camp, Wiltshire, that the suspected involvement of civilians in the killings, which took place in June 2003, may have led to increased hostility between the soldiers and their detainees.
The "general feelings of hostility and enmity" created by the soldiers facing a daily risk of death would have been heightened by such beliefs, said the prosecutor.
Mr Bevan said one of the accused, Major Michael Peebles, 35, of the Intelligence Corps, described the detainees as "suspected terrorists".
The court heard that he went to the holding facility with another soldier and told the guards "these guys [the detainees] might be involved in the RMP stuff" - a reference to the murder of the Red Caps.
Mr Bevan told the court: "Major Peebles said he told them this because he felt they ought to know they were dealing with dangerous individuals.
"But it must have been obvious to anyone that telling the guards that the detainees might be involved in the killing of the RMPs could only stoke any enmity the guards may have harboured towards the detainees, and thus increase hugely the risk of abuse to them."
Not guilty pleas
Cpl Donald Payne, 35, became the first soldier to admit to a war crime after he pleaded guilty to inhumanely treating Iraqi civilians.
Payne has denied two further charges - manslaughter and perverting the course of justice - relating to the same alleged ordeal suffered by nine Iraqis arrested in Basra, southern Iraq, in September 2003.
Payne's six co-defendants all plead not guilty to the charges brought against them.
Turning to the charge of negligently performing a duty that three of the soldiers face, Mr Bevan said they did not adequately ensure that Payne, the alleged leader of the abuse, and the other defendants, were treating the detainees humanely.
He told the court there were no orders in place on the handling of the prisoners.
The prosecutor said: "The consequences were that these detainees were held, cuffed, hooded, deprived of sleep and for the most part held in the stress position in extreme heat and increasingly unsanitary conditions for over 36 hours until the death of Baha Mousa.
"The result was that Corporal Payne and the guards were left to act as they wished, without any adequate directions and without any proper supervision or checks in place."
The stress position involves standing knees bent, with arms outstretched.
The prosecutor said the treatment of the detainees contravened the prisoners' rights within law to be treated humanely.
The case continues.