DUBAI (Reuters) - Iran has shut its consulate in the western Afghan city of Herat after anti-Iranian protests outside the compound, a foreign ministry official told state news agency IRNA on Tuesday.

The demonstrators were protesting against the alleged killing of Afghan migrants by Iranian police. The official made a formal complaint to the Afghan government over the incident, the agency said, without naming the official.

"The Islamic Republic of Iran is asking Afghan officials to be vigilant in preventing similar incidents in the future," IRNA quoted the official as saying.

The Afghan Interior Ministry said in November that Iranian police had killed 13 Afghan migrants after crossing the border in Herat, adding to 10 killed in August.

The Iranian official denied this, calling the accusation "baseless", IRNA reported.

(Reporting by Hamid Shalizi in Kabul and Yeganeh Torbati in Dubai; Editing by Tom Pfeiffer)