Vilks realized that something was wrong.
"We suddenly heard a lot of noise. There was a bang, bang, bang, and very quickly we could understand that something was going on," he told CNN's Fredricka Whitfield on Sunday.
Vilks' bodyguards sprung into action.
"They took me and threw me into a storage room together with the chairman," he said, "and we were put under a table there, and we were guarded by policemen with drawn guns."
Outside the storage room, Vilks said, a far more frightening scene was unfolding.
A heavily armed gunman was trying to get through the doors of the cafe. And the police were trying to stop him.
But it wasn't a fair fight.
"He was very well-equipped, and the policemen were not. So he had an advantage. ... Several of the policemen (were) wounded, but still they tried to fire back," Vilks said.
Inside the cafe, terrified audience members scrambled for cover.
"They were hiding in corners and under tables and everything," Vilks said. "They were just waiting (to see) who is going to open the door there and who will come in."
Luckily, Vilks said, it was a wounded policeman who finally entered the cafe -- not the gunman, who police later said they'd killed.
'I'm such a well-known target'
The artist wasn't hurt, but the gunman did kill a 55-year-old man and wounded three officers before fleeing, police said.
It's impossible to know for sure what the gunman's aims were, Vilks said. But Vilks said it's likely that he was the target. Controversial sketches Vilks made depicting the Prophet Mohammed in 2007 landed him on an al Qaeda hit list with a $100,000 bounty on his head and have sparked a number of threats and attacks against him
For many Muslims, any image of Mohammed is seen as blasphemous. Depictions that deliberately insult the Prophet are even worse.
Vilks receives regular death threats and regularly sweeps his car for explosives.
While speaking at a 2010 free speech forum, Vilks was punched at the podium amid cries of "Alahu akbar" -- Arabic for "God is great." The event quickly descended into a brawl.
"I'm now such a well-known target, and that adds to value, because these guys, they work very much concerned with the media interest, so if they want to kill someone, it should be someone who is well-known. ... And that means that when I go somewhere, I always have bodyguards," he said. "I can't go anywhere on my own."
Does the Denmark attack mean he'll pull back from public appearances?
Vilks said he plans to keep speaking out, but he told CNN on Monday that he'd gone into hiding
. He declined to specify when he first went into hiding and said he is not afraid.
Organizers of future events will take security very seriously, he said.
Islam and other religions, he said, should be open to criticism because their ideology is deeply tied to social and political issues.
"If you go into the political business, you have to play the game," he said. "And as long as that goes on, criticism of Islam is to be continued, and rightly so."
Vilks said his work and those who are discussing it are "part of a political conversation."
"And if you have people who want to go out with guns and start murdering people, the thing you should do is put these people in prison, because we cannot accept people murdering and trying in that way to stop the discussion you have," he said.
Such conversations, he said, are a key part of free speech and living in a democracy.
The one responsible for the violence "is of course not the one who is following the rules and keeping a reasonable discussion going," he said. "It's those people who try to stop it with violence and murder."