“If someone is deemed to be a risk for state security by intelligence services while staying abroad, they wouldn’t get a dime,” Mr. Nielsen said. He added that, under the proposed legislation, once a Danish court determines that a citizen has violated the law and joined the Islamic State, then Danish authorities could also demand the reimbursement of benefits already paid.

Dozens of militants have returned to Denmark after fighting for ISIS in the Middle East, and the country has been experimenting with ways to reintegrate the former fighters, including psychological counseling, education and job advice.

More than a decade ago, Denmark became a flash point for Islamic extremism after a Danish newspaper published caricatures of the Prophet Muhammad, spurring outrage and protests across the Muslim world. In February 2015, Omar Abdel Hamid El-Hussein, a 22-year-old Danish-born gunman of Palestinian descent, killed two people while targeting a Copenhagen synagogue and an event promoting free speech. He was later shot dead by police.

The efforts to tame Islamic radicalism in Denmark are occurring against the backdrop of a simmering culture war over Danish identity and the challenge of integrating immigrants, which has helped drive support for the far-right anti-immigrant Danish People’s Party.

This month, the Parliament approved a statement by the Danish People’s Party expressing concern that there were more immigrants than native-born Danes in some areas of Copenhagen.

“Parliament notes with concern that today there are areas in Denmark where the share of immigrants and descendants from non-Western countries surpasses 50 percent,” the statement said. “It is the opinion of the Parliament that Danes should not be a minority in neighborhoods in Denmark.” The statement, which was largely symbolic but generated a loud debate, also called for the government to limit the granting of asylum.

Opponents of the statement, which was supported by the government and its coalition partners and passed by a vote of 55-54, said it stigmatized Danish immigrants and citizens who were born of immigrant parents.