The staff member suffered light injuries and went to hospital under his own steam, police said in a statement.
Detectives are investigating the incident, aided by forensic and intelligence investigators, the statement added.
Ukraine’s embassy to Spain was not immediately reachable.
The area surrounding the embassy has been cordoned off, state broadcaster TVE reported.
(Reporting by Belén Carreño; Writing by David Latona; Editing by Aislinn Laing and Frank Jack Daniel)