US forces blocked off the area after the exchange of fire, said Maitham Abdul Rezzaq, a police spokesman. The police had initially reported that the mosque imam had been killed, but he was not hurt.
Rezzaq said the attackers hit the al-Nour mosque in the Jihad neighbourhood shortly after midnight and fought with mosque guards until about 12:30am (9.00 GMT)
On Sunday morning, several masked gunmen were guarding the mosque. Windows were broken, the exterior walls were pockmarked where they had been hit with bullets and dozens of spent casings lay on the road, where there were at least two unexploded hand grenades.
Sheik Shaker Mahmoud, the imam, told reporters that "a gang using ten cars stormed the mosque".
He said: "The cars used by the attackers are the same as those used by the interior ministry. The attackers were wearing military uniforms.
"They launched an attack on our mosque. They broke windows and stormed the courtyard."
Witnesses said US helicopters hovered above the gun battle. American forces moved in to stop the fighting and remove the dead and wounded.
Rezzaq said all the wounded appeared to be mosque guards. The identity of the three dead was not immediately known.