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

The assailant's motive for the attack, which took place on Sunday around 11:30pm (22:30 GMT), was unclear and video footage would be reviewed, a police spokesman said.

"The attacker stabbed the soldier repeatedly. He was only saved by a stab-proof vest," the spokesman said, according to Reuters news agency, adding that the two men ended up grappling on the ground.

"The soldier defended himself well and was then able to reach for his service weapon and fire shots," he added.

According to early indications he "acted within the rules", said a spokesman from the ministry of defence quoted by the national Austria News Agency.

The official added that the soldier, who is from the Tyrol region of Austria, had been treated in hospital.

Heightened security measures were ordered at embassies and other diplomatic buildings after the incident.

The incident comes just days after two knife attacks in Vienna, including one that left a couple and their 17-year-old daughter with severe injuries.

A 23-year-old Afghan national confessed to those assaults but denied any political motive.