The clashes overnight killed two people and injured nine, a police commander said. The officer, who spoke on condition of anonymity because he is not authorized to release the information, said it was unclear whether there were any casualties among the soldiers.
The reports of the latest setback for the Iraqi army come after government officials acknowledged that during fighting last month against Shiite militias in the southern city of Basra, more than 1,300 Iraqi soldiers and police deserted or refused to fight.
The police officer said militiamen belonging to the Mahdi Army of anti-American cleric Muqtada al-Sadr launched their attack shortly before midnight on army positions in Sadr City, a sprawling slum area of some 2.5 million people in eastern Baghdad.
The company responsible for that section withdrew, abandoning their positions, including their command post in al-Nasir police station, he said.
The officer did not know exactly how many troops were involved. An Iraqi infantry company normally has 150 men but many in the field are undermanned and have only 80-90.
U.S. troops responded with artillery fire, but no helicopters or unmanned drones were sighted, the officer said. There was no immediate comment from the Iraqi or U.S. military.
The attack in Sadr City occurred late Thursday while Baghdad was blanketed by one of the worst sandstorms in months. The thick clouds of dust reduced visibility and forced the closure of the international airport. It also appeared to affect military flights.
Armed helicopters have been used extensively to provide fire support to U.S. and Iraqi troops fighting in Sadr City since clashes with the Mahdi Army erupted there three weeks ago.
Apparently taking advantage of the reduced aerial activity, militants also repeatedly shelled the Green Zone that houses diplomatic missions and much of the Iraqi government.
On Friday, the Mahdi Army urged government troops to desert and described Prime Minister Nouri al-Maliki's government as "just like Saddam's."
"To all brothers in the government's forces of army and police commandos, we invite you to repent and rejoin the national line and embrace your suffering people," said the group's statement, which was printed on leaflets distributed throughout the city.
The failure of government forces to capture Basra last month despite superiority in numbers and firepower was an embarrassment to prime Minister Nouri al-Maliki, who ordered the offensive. It also raised serious questions about the army's discipline and morale.
The clashes in Sadr City come a day after a suicide bomber struck the funeral of two Sunni tribesmen who joined forces against al-Qaida in Iraq, killing at least 50 people and reinforcing fears that insurgents are hitting back after American-led crackdowns.
The sudden spike in bloodshed this week adds to the other worries now piling up in Iraq, including violent rivalries among Shiites and persistent cracks in the Iraqi security forces.
Also on Friday, Ayman al-Zawahri -- Al-Qaida's No. 2 man -- said in an audiotape that the United States will lose whether it stays in Iraq or withdraws.
The statement, released early on a militant Web site, was in reference to President Bush's statement that he would give U.S. commanders in Iraq all the time needed to reassess troop strengths in Iraq after the current drawdown of U.S. troops ends in July.
"The truth is that if Bush keeps all his forces in Iraq until doomsday and until they enter hell, they will only see crisis and defeat by the will of God," said al-Zawahri, the deputy of al-Qaida chief Osama bin Laden.
"If the American forces leave, they will lose everything. And if they stay, they will bleed to death," al-Zawahri said.
© 2008 Associated Press