Two rockets crashed into the outer wall of the Iranian consulate early on Tuesday while a third hit a police vehicle guarding the building. There were no casualties.
Police said they then foiled another attack on the compound, finding and defusing two rockets.
Iranian state television said the consulate was attacked by four mortar bombs, but that only a car was damaged.
It said two shells landed inside the consulate's grounds while two others hit its walls.
Also early on Tuesday, several mortar shells were fired at the large palace complex that houses the British consulate, a British army base, a UN office and several other organisations.
Only one actually hit the compound.
British military spokesman Major Charles Burbridge said: "These attacks happen from time to time."
In another incident, British soldiers shot dead a leader of the Shia militia, Mahdi Army, during an overnight gun battle in Basra in which a British soldier was wounded.
He said as they moved towards the area, they came under fire from a building, and one British soldier was wounded in the ensuing firefight.
British grenades were found at the
scene of the clash
The British soldiers killed one man inside the building.
Burbridge said the man was suspected of involvement in executions in Basra and to have been "linked to quite nasty criminal activity".
Meanwhile, in western Baghdad, a car bomb exploded near a petrol station in the Hay al-Amil district, killing two civilians and wounding 25 more.
Elsewhere, assailants killed Faris Egab, mayor of Udhaym town, in a drive-by shooting, police said.
In central Baquba, armed men opened fire on a police patrol near the city's prison, killing a policeman and wounding three others, the office said.
Also on Tuesday, the US military reported that three US soldiers had died in recent separate incidents in Baghdad.
One soldier was killed when his vehicle struck a roadside bomb in northeast Baghdad while a second was killed by small-arms fire shortly afterwards in north-central Baghdad, both on Sunday.
On Monday, a soldier in the medical task force which provides health care in Iraq died of "non-battle related injuries", the US military said without elaborating.