The soldier sprayed the man with pepper spray before firing four shots, spokesman Harald Soeros said.
The assailant, a 26-year-old Austrian citizen, "died on the spot," he added. The soldier was taken to hospital with a stab wound to his upper arm.
Unclear motiveA Defense Ministry spokesman quoted by the APA agency said it appeared the soldier had "acted within the rules" by first trying to repel the attacker with pepper spray.
Police said it was too early to speculate on a motive. They've sent additional security personnel to other diplomatic buildings across Vienna.
The incident comes just days after four people were seriously injured in a stabbing rampage in the Austrian capital. A 23-year-old Afghan man later confessed to those attacks.
nm/jm (AFP, dpa)
Each evening at 1830 UTC, DW's editors send out a selection of the day's hard news and quality feature journalism. You can sign up to receive it directly here.