(CNN) -- The Swedish cartoonist whose depiction of the prophet Mohammed as a dog has elicited death threats was the object of an attempted attack Tuesday at Sweden's Uppsala University, police said.
The cartoonist, Lars Vilks, was not hurt, though a police officer was, said Jonas Eronen, commissioner with the Uppsala police.
Two people were arrested, he said.
When Vilks entered a classroom where he was to deliver a lecture to about 250 people -- all of whom had passed through a security checkpoint to gain admission -- about five people started protesting loudly, Eronen said.
After Uppsala uniformed and non-uniformed police calmed the protesters, the lecture got under way at about 5:15 p.m. (11:15 a.m. ET), Eronen said.
But as Vilks was showing audiovisual material, 15 to 20 audience members became loud and tried to attack Vilks, he said.
As police stepped in, a commotion started and Vilks was taken to a nearby room; police used pepper spray and batons to fend off the protesters, Eronen said.
Vilks did not return to the lecture.
Last March, an American woman who called herself "Jihad Jane," Colleen LaRose, was indicted in the United States for allegedly conspiring to support terrorists and kill Vilks.
In 2007, Vilks told CNN he had drawn the cartoon of Mohammed with a dog's body in order to take a stand. "It should be possible to insult all religions in a democratic way," Vilks told CNN from his home in rural Sweden. "If you insult one, then you should insult the other ones."
Dogs are considered unclean by conservative Muslims, and any depiction of the prophet is strictly forbidden.
Vilks said his drawing was a calculated move, and he had wanted it to elicit a reaction.
"That's a way of expressing things. If you don't like it, don't look at it. And if you look at it, don't take it too seriously. No harm done, really," he said.
He was defiant in the face of suggestions that his work insults Muslims.
"No one actually loves the truth, but someone has to say it," he said.
The self-described atheist said he is an equal-opportunity offender who has sketched a depiction of Jesus as a pedophile.
Vilks' cartoon depicting Mohammed came on the heels of Muslim outrage about cartoons originally published in Denmark in 2005. The republication of the cartoons several months later sparked violent protests in the Muslim world and prompted death threats against the cartoonist.
Vilks' cartoon, which was published in August 2007 by the Swedish newspaper Nerikes Allehanda, did not provoke that level of global protest, although it has stoked outrage.
Muslims in Sweden demanded an apology from the newspaper, which stood by Vilks.
Pakistan and Iran also lodged formal protests with Sweden.
CNN's Per Nyberg contributed to this story from London.