Swiss police cordoned off the mission after a report that hostages were being held inside.
State radio later announced that three hostage-takers had left the consulate on Monday and a ministry spokesman said a security guard had been stabbed and injured with a knife during the incident.
But Spanish Foreign Minister Miguel Angel Moratinos said on national radio that all employees were safe.
"The hostage situation is over," an official said, but declined to comment on the circumstances." The police are now investigating."
The police have yet to confirm whether the attack has come to an end.
"The hostage situation is over. The police are now investigating"
"At around 8am (0700 GMT) a man entered the consulate. He hit a doorman over the head," a Spanish embassy official had said on Monday.
The official had added they were "holding one or two people".
The motive remained unclear.
Swiss radio reported that two employees, a man and a women, had been held, but neither Swiss police nor the Spanish Foreign Ministry in Madrid were able to confirm the report.
Nevertheless, police sealed off part of the Kirchenfeld district where the consulate is situated and set up a crisis centre specialised in hostage-taking situations, a police spokeswoman said.
Swiss radio reported that elite sharpshooters had been posted on buildings near the consulate.