Iraqi police said 22 people had died in the fighting on Sunday after armed men opened fire on US soldiers in the area.
Hasan Hamud, a police lieutenant, said eight people had been wounded and some of the casualties were at an office belonging to the Dawa party near the mosque.
The incident started when US forces came under fire from an unknown source in the direction of the mosque and the party office, Hamud said.
The American military said 16 "insurgents" were killed in the Ur neighbourhood by Iraqi special forces with US troops on the scene as backup.
"No mosques were entered or damaged during this operation," the military said in a statement, at least five hours after the incident.
"As elements of the 1st Iraqi Special Operations Forces Brigade entered their objective, they came under fire. In the ensuing exchange of fire... [Iraqi troops] killed 16 insurgents. As they secured their objective, they detained 15 more individuals," the statement said.
Associated Press videotape from the scene showed a tangle of dead male bodies with shotgun wounds on the floor of what was said to be the living quarters of the imam, attached to the place of worship.
"How can these men be executed outside the law? The lives of Iraqis are not cheap. If the American blood is valuable to them, the Iraqi blood is valuable to us too. We demand an immediate investigation and that the Iraqi side be involved in the investigation"
Haidar al-Ubaidi, MP
The tape showed 5.56 mm shell casings scattered about the floor. US forces use that calibre ammunition. A grieving man in white Arab robes stepped among the dead bodies strewn across a bloody floor.
Abd al-Zahra al-Suaidi, a representative of Shia cleric Muqtada al-Sadr's office in Baghdad, said US forces and Iraqi army soldiers opened fire at al-Mustafa Shia mosque in the Ur neighbourhood, killing 18 people in what he called was an unprovoked attack.
Haidar al-Ubaidi, a politician and a senior official of the Dawa Party of Ibrahim al-Jaafari, the prime minister, was outraged when reached by AP.
"How can these men be executed outside the law?" he said.
"The lives of Iraqis are not cheap. If the American blood is valuable to them, the Iraqi blood is valuable to us too. We demand an immediate investigation and that the Iraqi side be involved in the investigation."
Shia figure al-Sadr (C) was also
the target of an apparent attack
Salam al-Maliki, an official of al-Sadr political bloc, said American forces had surrounded the hospital to which the wounded were taken.
"It is an escalating plan by the US to draw the Sadr bloc to a crisis," he said. "What is going on is a big conspiracy plotted by America against Iraq to create sedition and sectarianism."
The new violence, in an area dominated by al-Sadr's organisation, was reported just hours after he personally was the apparent target of a mortar attack at his home in Najaf, 150km south of Baghdad.
At least one mortar round slammed to earth within 50m of al-Sadr's home, wounding one guard and a passing child, said Shaikh Sahib al-Amiri, an al-Sadr aide.
Shortly after the attack, al-Sadr issued a statement calling for calm.
"I call upon all brothers to stay calm and I call upon the Iraqi army to protect the pilgrims as the Nawasib [militants] are aiming to attack Shia every day," he said, referring to Wednesday's commemoration marking the death of Prophet Muhammad.
A day earlier, seven people were killed during a gunbattle between forces of al-Sadr's al-Mahdi Army militia and Sunni fighters near Mahmudiya, about 33km south of the capital. Most of the dead were civilians killed in their homes by mortar fire.