TUNIS — The Tunisian prime minister has embarked on a sweeping crackdown against organized crime, arresting nearly a dozen mafia bosses and smuggling barons in recent weeks in an effort to stamp out what has become a nearly existential threat to the young democracy.

The campaign, led by Prime Minister Youssef Chahed, is proving popular among Tunisians frustrated at increasingly brazen corruption, a stagnating economy and an ever-widening gap between rich and poor.

The drive has surprised nearly everyone for its vigor, but it is not without risks, as the mafia bosses have become so powerful that financial and political analysts say they present a threat as dangerous as terrorism.

“It is a war, not a one-off battle,” Mr. Chahed, 41, a soft-spoken agricultural engineer, who worked for several years on development programs at the United States Embassy in Tunis, said in an interview this month. “We are going to continue to the end. It is very important for the Tunisian economy, for the security of the territory.”