PARIS—French police have questioned an 8-year-old boy after he allegedly made comments in support of terrorists, part of a controversial crackdown on extremist propaganda in the wake of this month’s deadly attacks in the capital.

Police in the French city of Nice said Thursday that they have questioned a boy and his father to determine how the boy picked up what they describe as “alarming statements” in support of the gunmen who killed 12 people in a terrorist attack on French satirical newspaper Charlie Hebdo on Jan. 7.

“I’m with the terrorists,” the boy—identified only as Ahmed—said in class discussions, according to Sefen Guez Guez, a lawyer for the family. He says the boy didn’t understand the meaning of the word “terrorist” and described the decision to refer him to police as “total insanity.”

The father and son weren’t held by police.

The investigation into the circumstances surrounding the boy’s alleged remarks, which police say is continuing, underscores the challenge France faces in balancing free speech with combating terrorism. Last fall, the government increased penalties for condoning or inciting terrorism by moving the provision from a less-enforced press law into the national penal code to stem terrorist recruitment in France.