The artist, for his part, said that he was surprised and hurt by the controversy.

“It was an enormous surprise to see some people, not even many of them, contest the statue,” Mr. Abella said in a phone interview.

“Segovia is a normal city with normal people,” he added, “and it hurts me to see the image of the place where I have lived for some 30 years damaged by this.”

To Mr. Abella, the statue has nothing to do with religion. It refers to a Segovia myth that the Devil, not the Romans, had given the city its famous aqueduct, which towers 90 feet over the Old Town of Segovia.

According to the legend, the Devil offered a deal to a young girl who was tired of dragging water through the city’s steep streets: He would get the water to her home before dawn, in return for her soul. As the Devil labored all night to build the aqueduct, she prayed. A storm came, holding up the Devil’s work, and in the end, he lost his bid by one stone.

Ms. Lazaro said the statue was a departure from the true message of the legend: to “take care of one’s soul and repent.”

In recent years, Spain has seen similar high-profile court cases led by the Spanish Association of Christian Lawyers. The association has mostly used an article in the Spanish criminal code that forbids “offending the feelings of members of a religious confession.”

In 2014, the association tried to remove the director of the Reina Sofia art museum in Madrid for displaying artwork that alluded to burning churches. In 2017, it filed a complaint against a drag queen who performed as the Virgin Mary and Jesus on the cross. And the actor and theater producer Willy Toledo was briefly detained by the police last year after he ignored a court summons for publishing insults about God and the Virgin Mary online. He is still awaiting trial.