The 200-strong crowd threw rocks and broke consulate windows before security forces drove them back by firing warning shots into the air, an AFP correspondent at the scene said.
The crowd claimed 13 Afghans who had crossed the border into Iran were seized and later shot dead by Iranian security forces about three months ago.
"Over the past several months we have been demanding the Iranians return the bodies of our relatives but they are not returning them," one protester told AFP.
Protesters shouted slogans against Iran and its President Mahmoud Ahmadinejad and said they would "support the United States if it invades Iran".
Dozens of police blocked the crowd as it tried to storm the Iranian consulate, the AFP reporter said. The mob later gathered around the governor's house and continued shouting anti-Iran slogans, he added.
A consulate official, quoted by Iran's ISNA news agency, said Tehran had "no proof" that these immigrants had entered the country -- whether legally or illegally -- or that they had died in Iran.
"Several months ago we delivered visas, at the request of the Afghan foreign ministry, to three or four individuals who wanted to enter Iran to clarify the situation," the official said.
"They came and upon their return provided no proof to back their accusations," he added.
About 2.4 million Afghans -- refugees and illegal immigrants -- live in Iran, many of whom moved after the 1979 Soviet invasion. Afghans continue to migrate to Iran and Pakistan in search of work and for political reasons.
Crossing the border with the help of local human traffickers, migrants sometimes end up being jailed by Iranian border guards.
Relations between Tehran and Kabul are apparently normal but ordinary Afghans accuse Iran of committing atrocities against Afghan refugees and executing Afghan prisoners.