The attack follows warnings from Shiite militants backed by Iran and anti-American cleric Muqtada al-Sadr that they would violently resist any effort to keep American troops in Iraq past their year-end deadline to go home.
Although American casualties have dropped considerably in the two years since U.S. troops pulled back from Iraq cities, Shiite militias have begun hammering U.S. bases and vehicles with rockets, rocket-propelled grenades and roadside bombs over the past three months.
The militants' goal appears twofold: to give the impression that they are driving the withdrawing U.S. forces out of Iraq, and to make the U.S. think long and hard before agreeing to any Iraqi request to keep a contingent of troops in this country beyond the end of the year.
"Iranian-backed militias are flexing their muscles and have steadily increased military pressure on U.S. forces since rumors first started in the early spring concerning an extension of the U.S. presence," said Michael Knights, an Iraq analyst at the Washington Institute.
Washington has been pressuring Baghdad to make a decision on whether it wants American forces to stay past Dec. 31 to help with such missions as protecting Iraq's airspace and training Iraqi forces.
Although few Iraqis will say this in public, many feel their own security forces are ill-equipped to keep a lid on violence and secure their borders without the assistance of the Americans.
Violence around Iraq has dropped dramatically since the insurgency's most deadly years in 2006 and 2007.
But eight years into a war often perceived as all but over, the deaths of the five U.S. soldiers and 11 Iraqis killed in other attacks around the country Monday underscore the persistent dangers here.
The violence also shows the threat Iranian-backed militias pose to U.S. forces if they stay longer and the potential backlash that Iraqi political leaders face if they support an extension.
The U.S. military said the five soldiers died Monday morning at a base in eastern Baghdad that was hit by indirect fire, the military's term for mortars or rockets.
Two Iraqi security officials later said three rockets slammed into a joint U.S.-Iraqi base in the Baladiyat neighborhood near the U.S. forces' living quarters. The American troops are partnering with Ministry of Interior forces. The Iraqi officials spoke on condition of anonymity because they were not authorized to speak to reporters.
Baladiyat is a Shiite neighborhood that borders Sadr City, a slum in eastern Baghdad that is the stronghold of anti-American cleric Muqtada al-Sadr. The Shiite cleric with ties to Iran has made opposition to the U.S. troops a core issue among his followers.
Thousands of his militia members, called the Mahdi Army, flooded the streets of Sadr City in a rally two weeks ago. They didn't carry weapons but the threat was clear.
Al-Sadr told the BBC he would unleash the Mahdi Army on American forces if they do not withdraw and that his supporters were already targeting U.S. bases and vehicles.
Maj. Gen. Jeffrey Buchanan, the military's spokesman in Iraq, said attacks on U.S. forces in Baghdad and southern Iraq began to increase in March.
In January and February, the U.S. military recorded an average of about three attacks per day. By May, that number jumped to almost six per day. An attack could be anything from a single sniper shot at U.S. troops to a complex attack involving roadside bombs and gunfire.
"We're going to continue to defend ourselves and work with the Iraqi security forces," he said. "They're not going to deter us."
The five fatalities Monday were the most in a single day since May 11, 2009, when five troops died in a noncombat incident. On April 10, 2009, six U.S. troops died - five in combat in the northern city of Mosul and one north of Baghdad in a noncombat related incident.
According to an Associated Press tally, 4,459 American service members have died in Iraq since the war began in 2003.
At the height of the surge of U.S. forces four years ago to combat sectarian violence that nearly tore Iraq apart, there were about 170,000 American troops in the country. The number then was gradually drawn down to below 50,000 when Washington announced it had ended its combat operations 10 months ago.
The roughly 46,000 U.S. troops still in the country focus on training and assisting Iraqi security personnel, but are to shun combat.
U.S. Defense Secretary Robert Gates has said he thinks the U.S. would agree to stay into next year if Iraq asks. Doing so, however, would break a campaign promise by President Barack Obama.
"The U.S. public just does not want to hear about Iraq right now. Iraq is totally off the radar screen right now in Washington," said Marina Ottoway, director of the Middle East Program at the Carnegie Endowment for International Peace.
Eleven people were killed in political violence across Iraq on Monday:
- A bomb exploded at a checkpoint outside a government compound in Tikrit, the hometown of Saddam Hussein. It was the second attack in four days against the compound and the government employees who live and work there. Mohammed al-Asi, a media adviser to the provincial governor, said four people died.
- Gunmen in speeding vehicles attacked two checkpoints in a Sunni neighborhood in northern Baghdad, police and medical officials said. Four people were killed.
- Attackers bombed the house of a police colonel near Ramadi, the capital of the mostly Sunni Anbar province. The colonel survived the attack and was taken to the hospital. His wife, mother and son were all killed.
The officials all spoke on condition of anonymity because they were not authorized to speak to the media.
Associated Press writers Qassim Abdul-Zahra and Sinan Salaheddin contributed to this report.