BAGHDAD - The US military was investigating Tuesday the killing of five American soldiers at its largest base in Iraq after detaining one of their comrades suspected of carrying out the shooting.

The US soldier, whose name has not been released, was in custody after allegedly firing on his colleagues at a counselling clinic in the sprawling Camp Liberty in Baghdad.

"The investigation is ongoing," the US military said on Tuesday after earlier saying it had detained a soldier at the base lying northeast of central Baghdad.

Details of exactly what happened are still emerging but US defence and military officials have said that five soldiers died and three were wounded in the shooting.

US President Barack Obama said on Monday he was "saddened" and "shocked" by the killings and promised to closely examine the tragedy.

"I will press to ensure that we fully understand what led to this tragedy, and that we are doing everything we can to ensure that our men and women in uniform are protected as they serve our country so capably and courageously in harm's way," Obama said in a statement.

US Defence Secretary Robert Gates voiced "horror and deep regret" over the slayings and said the case would be top of the agenda for his department.

"If the preliminary reports are confirmed, such a tragic loss of life at the hands of our own forces is a cause for great and urgent concern," Gates said at a press conference in Washington.

"And I can assure you that it will get this department's highest priority attention."

The attack was the single deadliest toll of US forces in Iraq since April 10 when five soldiers were killed by a suicide truck bomb in the northern city of Mosul.

In the last such reported incident, US media widely reported that Sergeant Joseph Bozicevich, 39, had allegedly shot dead two of his superiors at a base south of Baghdad last September 14.

The dead men were named as staff sergeant Darris Dawson, 24, and sergeant Wesley Durbin, 26, and the reports said Bozicevich could not bear being berated by them.

Such incidents are not common but nearly a fifth of American soldiers deployed in Iraq suffer Post-Traumatic Stress Disorder (PTSD), according to the US military's battlemind.army.mil website.

Monday's attack in Baghdad comes at a sensitive time in the US military's six-year-old occupation of the country it invaded in 2003 to topple Saddam Hussein.

A spate of recent violence in the capital has raised concerns about whether Iraqi security forces are battle-ready as US forces prepare to withdraw from the nation's cities.

Baghdad has been hard hit by a series of deadly bombings targeting crowded civilian areas in recent weeks, and April was the bloodiest month in Iraq since September, with 355 people killed, according to official figures.

Despite the recent attacks, Iraq has insisted it will stick to the deadline for American troops to withdraw from cities by June 30, while Washington's top commander in Iraq, General Ray Odierno, has insisted the pullout is on track.

The drawdown is part of a military accord signed between Washington and Baghdad that will see US forces leave Iraq completely by the end of 2011. The United States currently has about 139,000 troops in Iraq.

A total of 4,294 American troops have died since the US-led invasion of Iraq in March 2003, according to an AFP count based on the independent website icasualties.org.

Despite the dramatic improvement in security across the country over the past two years, Iraq has seen a spike in attacks in recent weeks that have killed hundreds and wounded even more.

On Tuesday a suicide bomber aboard a small pick-up truck slammed into an Iraqi police patrol in the tense northern city of Kirkuk, killing six people and injuring 14, police said.