BAGHDAD - Five American soldiers died yesterday when a barrage of rockets slammed into a base in a Shiite neighborhood of Baghdad - the largest, single-day loss of life for U.S. forces in Iraq in two years.

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.

Washington has been pressuring Baghdad to decide 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 deadliest 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 the killing of 11 Iraqis in other attacks yesterday underscore the persistent dangers here.

The violence also shows the threat that 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 yesterday 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.