A 26-year-old Austrian was shot dead outside the Iranian ambassador's residence in Vienna on Sunday night after he attacked a guard with a knife, police said.

The assailant "died on the spot" after the soldier opened fire, police spokesman Harald Soeros told AFP, adding that the attack took place just before midnight local time.

The motive for the attack is not yet known, police said.

The soldier, who was standing guard outside the building, suffered a wound to his upper arm in the attack.

"He initially used pepper spray" against the assailant, Soeros said, before opening fire. He was believed to have fired his weapon at least four times.