Outside the courthouse, 16 armed police officers screen all comers, including hundreds of lawyers in flowing black robes. Beyond a wall of barbed wire, a throng of bearded young men angrily shout slogans. The scene sends a clear message: Could be trouble here.

The subject of all this attention is a short, hyperactive, wise-cracking TV mogul who smokes fat stogies, has 25 bodyguards on his payroll and is on trial over charges of libeling Islam.

Nabil Karoui owns the HBO of Tunisia, a satellite TV channel called Nessma (“Breeze”) that shows Hollywood movies and TV series.

A week before Tunisians voted in the fall for their first freely elected government since 1956, Nessma aired the French-language animated movie “Persepolis,” based on an Iranian exile’s graphic novel about a girl who comes of age during Iran’s 1979 revolution. In the weeks after the broadcast, Karoui’s house was destroyed by a mob of vandals and Nessma’s offices were repeatedly attacked — all because of a short scene in which the girl imagines herself talking to God, who appears as an old man with a long, white beard.

Now, Karoui’s on trial, and so is Tunisia’s year-old revolution and the young democracy it has wrought. For hundreds of years, Tunisia has boasted a complex blend of Islamic and Western values, and now, having ousted their autocratic leader, Tunisians are struggling to find the right balance. No part of that wrenching, sometimes violent debate has been more divisive than the issue of freedom of speech.

Last month, on this capital city’s main boulevard, Islamist activists attacked actors who were celebrating World Theater Day; Islamists smashed musical instruments and hurled eggs. A hard-line preacher stood in front of Tunis’s Grand Synagogue and called for the murder of Tunisian Jews. And a Tunisian philosopher who showed up at a TV station for a debate on Islam was shouted down by extremists, who said he was no scholar of the faith because he has no beard.

In each case, calls for a state crackdown on offensive speech banged up against cries for the government to defend even unpopular expression. Karoui’s day in court became a nonstop, seven-hour shoutfest that will determine whether he is fined, imprisoned, or worse. A verdict is expected Thursday.

In Tunisia, defendants hire a lawyer, but any lawyer in the land may join the prosecution or defense, and those lawyers have the same right to argue in court as hired attorneys. The result: a pulsating black mass of robed men (and a handful of women) surging to the front of Courtroom 10, each with his own view of what should be done to Karoui.

Shouldn’t the death penalty be considered, asks lawyer Nasser Saidi: “Anything related to God is absolute. This was a test of the Tunisian people’s ability to defend God, and they have passed the test.”

No, five years max, says Karoui’s chief attorney, Omar Labiadh. But how can this case even be in court, he asks. Before the revolution, he says, “ ‘Persepolis’ was broadcast at least five times on Tunisian TV.”

The two sides argue as if they live in different galaxies. They cite different laws — God’s and man’s. They base their arguments on different histories — Western traditions of transparency and individual rights vs. Islamic concepts of Koranic authority and the obligations of the community of believers.

“These lawyers who speak against Karoui have no right to base a case on public opinion,” says Karoui attorney Faouzi Ben Mrad. To prosecute someone just for violating a religious commandment would be folly, Mrad says. For example, Mohammed Bouazizi, who sparked the Tunisian revolution by burning himself to death, “committed a sin by committing suicide. Now he is the symbol of our revolution. Are you going to prosecute him, too? This is Tunisia, not Kandahar or Pakistan. From Carthage to Mohammed Bouazizi, Tunisia has a different history.”

‘It was hysteria, craziness’

Karoui thought he had problems under the old regime. Tunisia’s longtime despot, Zine el-Abidine Ben Ali, refused permission for a privately owned channel to compete against state TV, so Karoui launched Nessma as a pirate station, without a license. His billboards were defaced and his advertisers harassed.

When Karoui finally won the right to broadcast from Tunisia, he played it safe, steering clear of political content and focusing on sports, television series such as “House” and music. But when the revolution broke out about 17 months ago, Karoui defied Ben Ali’s ban on political programming and switched to an all-news format.

Today, he has a mix of programs, a news staff of 50 and a clear position: “We are modernists, not Islamists,” he says. “We oppose sharia law and four wives. We show decolletage and miniskirts, and the extremists hack our Web site to retaliate.”

Karoui, 48, offers programs that put a Western face on Tunisia — and draw big ratings. “What we show, young people would watch even if we didn’t show it, but they’d watch it on HBO or the French channels,” he says. “Our vision is to push the country to be more modernist, but we understand the limits — no nudity, because this is a Muslim country.”

The decision to air “Persepolis” was very much about sending a message, Karoui says. He saw the story of the Iranian revolution as a cautionary tale for Tunisians “because every day in Iran, the Islamists took away one piece of freedom, and after two years of that, they took over the country.”

Before “Persepolis” aired, Karoui’s standards director glanced over a few minutes of the film and said, “It’s okay, it’s a cartoon.” The movie aired and got a lousy rating, no more than 50,000 viewers.

But as soon as the broadcast began, Nessma’s Facebook page filled with rants calling the station traitorous and attacking Karoui as a Jew and a Mason, neither of which he is. Two days later, 500 protesters arrived at the studios, threatening to burn the building.

“It was hysteria, craziness,” says Karoui, who watched from his top-floor office as protesters pushed toward his front door. “I understand that some people were offended, but please: No one watched the movie!”

Karoui went on Nessma to apologize to anyone who was offended, but on the following Friday, clerics at some mosques urged worshipers to take their anger to Nessma’s office. Police told Karoui that they could not protect him and urged him to go into hiding.

The next day, Karoui’s house was firebombed and trashed. “I had nothing left — no art, no furniture, no glassware,” he says. Fourteen attackers were arrested and fined $6 each.

Karoui has had to build a safe room in his house, stocked with a week’s worth of food.

“It’s very weird: I’m a Muslim, I fast on Ramadan, but I can’t go to mosque with my father and my son,” Karoui says. “I have 100 videos of religious leaders saying, ‘You must kill Karoui, cut off his right hand and take his eyes out.’ And the crazy thing is, I’m still optimistic about my country.”

Ruling coalition in a bind

The moderate Islamist party that leads Tunisia’s new governing coalition would like the Karoui case and others like it to go away. “It’s very difficult to put in place red lines on freedom of speech,” says Rachid Ghannouchi, spiritual leader of the Ennahda party. “Boundaries are set by society, and society changes. We are free to believe what we want, but we are not free to speak against others’ beliefs.”

Ghannouchi says he thinks Karoui intentionally aired “Persepolis” just before the elections to provoke violence by Islamist extremists, thereby sullying the image of all Islamists. “But we didn’t fall into this trap,” he says. “We defended his freedom of speech and said there should be no prison sentence.”

That position does not sit well with more hard-line Islamists, who want the state to silence Nessma and punish what they view as hate speech.

“Each country has its own view of free expression,” says Rafik Ghaki, a 33-year-old lawyer who heads a coalition of ultraconservative Islamists known as Salafists. “We do not oppose free expression, but it must have limits to protect the beliefs of others. We are for freedom, but an organized freedom.”

Ghaki argued against Karoui in court and organized a street protest last month against a Tunisian man alleged to have flushed pages from the Koran down the toilet.

That protest collapsed into violence, as Salafists attacked a crowd of actors celebrating World Theater Day down the street.

“The problem is there is no communication between these two parts of society,” Ghaki says. “We have youth in a new movement, and some of them get overexcited. And then some of the elite is against religion and Islam.”

It would be a mistake to expect Islamists to accept Western notions of free speech, Ghaki says: Airing “Persepolis” “in a very unstable period is not a patriotic act. As a civilized person, if that happens, I will go to the law for redress.”

Courtroom shoutfest

In Courtroom 10, anti-Karoui lawyer Seifeddine Makhlouf thunders against the audacity of those who defend the broadcast of an image of God: “Am I defending God here? Yes, because the Koran says if you support God, He will support you.”

After three hours of such arguments against Karoui, his defenders get their turn. They, too, speak of God’s will.

“You arrogantly claim to defend God,” roars defender Mourad Selimi. “No one can defend God. He defends himself. No, this case must be dismissed. This case will determine whether a revolution really happened here.”

But by this point, the lawyers on the other side have left the room; Karoui’s defenders shout only to one another and the judges, who stare impassively, silent amid the cacophony of freedom.