Gunmen sprayed grenades and automatic weapons fire Monday at shoppers in a market south of Baghdad, killing at least 50 people, mostly Shiites, in a major escalation of sectarian tension. The dead and wounded included women and children, hospital officials said. Three U.S. soldiers also were killed in separate attacks around Iraq.

Angry Shiite lawmakers stormed out of parliament to protest the attack, accusing U.S.-trained Iraqi police and soldiers of standing idly by while the killers — presumed to be Sunnis — went on a rampage in Mahmoudiya, 20 miles south of the capital.

CountryWatch: Iraq

Details of the assault were unclear. But several witnesses, including municipal council members, said the attack began when gunmen opened fire on the funeral for a member of a Shiite militia, the Mahdi Army, killing nine mourners.

Assailants then drove to the nearby market area, killing three soldiers at a checkpoint and firing grenades and automatic rifles at the terrified crowd. After the gunmen sped away, they lobbed several mortar rounds into the neighborhood, the witnesses said.

The deadly assault occurred a few hundred meters (yards) from Iraqi army and police positions, but the troops did not intervene until the attackers were fleeing, the witnesses said. They spoke on condition of anonymity because of fear of reprisals.

The U.S. command announced that three American soldiers were killed in separate attacks Monday — two in the Baghdad area and one in Anbar province west of the capital.

A U.S. statement said one soldier was hit by small arms fire early in the day in western Baghdad and died at 12:55 p.m.

Another soldier died at 4:55 p.m. from injuries suffered in an explosion south of the capital, the military said in a separate statement.

The third soldier, assigned to the 1st Brigade, 1st Armored Division, died Monday "due to enemy action" in Anbar province west of the capital, the military said.

Names were withheld pending notification of kin.

There were conflicting figures on casualties from the market attack, with a Shiite television station reporting more than 70 dead. But local police and Dr. Dawoud al-Taie, director of the Mahmoudiya hospital, said 50 people were killed and about 90 were wounded.

In Baghdad, prominent Shiite legislator Jalaluddin al-Saghir said Iraqi military authorities had ignored warnings that weapons were being stocked in a nearby mosque. He also said the local police commander refused to order his men to confront the attackers because they lacked weapons and ammunition.

Dozens of Shiite lawmakers, including followers of radical cleric Muqtada al-Sadr, stormed out of a parliament session to protest the performance of the security forces.

In Mahmoudiya, long a flashpoint of Shiite-Sunni tension, tempers boiled as frantic relatives milled about the hospital, scuffling with guards and Iraqi soldiers who tried to keep them outside so doctors could treat their relatives.

"You are strong men only when you face us, but you let them do what they did to us," one man shouted at a guard.

In Baghdad, the Shiite television station Al-Forat broadcast strident quotes from Shiites who blamed the attack on Sunni religious extremists. They expressed outrage that Sunni politicians cannot rein in Sunni extremists.

But the main Sunni bloc in parliament said the attack may have been retaliation for the kidnapping of seven Sunnis whose bodies were found Sunday in Mahmoudiya. The bloc accused Shiite-dominated Iraqi security forces of failing to control the situation.

The events also raised doubts about the effectiveness of the U.S. strategy of handing over large areas of the country to Iraqi control, while keeping U.S. troops in reserve in case the Iraqis need help.

U.S. troops of the 101st Airborne Division reported hearing detonations and gunfire, the U.S. command said in a statement. But Iraqi troops are responsible for security in the town, and American soldiers do not intervene unless asked by the Iraqis.

Four soldiers and a former soldier from the division are accused of raping and murdering a teenager near Mahmoudiya on March 12. A sixth soldier is accused of failing to report the crime.

The Mahmoudiya attack was part of a rising tide of tit-for-tat killings and intimidation that many Iraqis fear is the prelude to fullscale civil war. The campaign of intimidation and attacks is slowly transforming Baghdad into sectarian zones under the tacit control of armed groups that protect members of their sect and drive away the others.

On July 9, Shiite militiamen swept through the mostly Sunni neighborhood of Jihad in western Baghdad, dragging Sunnis from their cars and shooting them in the street. About 50 people were slain.

Faced with such horrific massacres, Iraqis are turning to sectarian militias to protect them because government forces cannot. Some Sunnis, who form the foundation of the insurgency, now say privately they want American troops to remain in Iraq to protect them from Shiite militias.

Despite the security crisis, Commerce Secretary Carlos Gutierrez arrived in the Iraqi capital Monday and signed an agreement with the Iraqis to encourage foreign investment and lay the foundation for a market economy after decades of state control.

"We are convinced that Iraq is ready for recovery," Gutierrez told reporters, later acknowledging that "clearly, security is still the No. 1 challenge."

Also Monday, the final group of Japanese troops left Iraq and arrived in Kuwait, ending Japan's two-year humanitarian mission in southern Iraq. The rest of the Japanese contingent, which had numbered more than 600, left over the past two weeks.