The Islamic State (IS) group claimed responsibility for the rare assault in the southwestern city of Ahvaz, while Iranian officials blamed "a foreign regime" backed by the United States.
A local journalist who witnessed the attack said shots rang out for 10 to 15 minutes and that at least one of the assailants, armed with a Kalashnikov assault rifle, wore the uniform of Iran's Revolutionary Guards.
"We realised it was a terrorist attack as bodyguards (of officials) started shooting," Behrad Ghasemi told AFP. "Everything went haywire and soldiers started running."
"The terrorists had no particular target and didn't really seem to care as they shot anyone they could with rapid gunfire."
Ahvaz lies in Khuzestan, a province bordering Iraq that has a large ethnic Arab community and has seen separatist violence in the past that Iran has blamed on its regional rivals.