The seven French citizens, wearing sandals and yellow jumpsuits, were brought before an Iraqi judge in a Baghdad courtroom this week to answer for their offense: joining the Islamic State.Each admitted to having thrown in his lot with the militants, working as tax collector, Arabic teacher, military trainer, chicken seller, medical aide or fighter.If there was evidence that any had committed a violent crime, it was never presented. Most had not even seen a lawyer until moments before being escorted into the courtroom.And yet after seven trials over four days, Judge Ahmed Mohamed Ali delivered seven identical sentences: death by hanging.The Frenchmen were among the roughly 4,000 foreigners captured in Syria and Iraq after the rout of ISIS, and they pose an international dilemma: Most of their home countries don’t want them back.The trials have drawn world attention as a test of whether Iraqi courts can meet international standards for a fair trial, and provide a just solution to one of the most vexing problems left in the aftermath of the battle against the Islamic State: what to do with its legions of followers.A terrorism court in Baghdad where seven French citizens were sentenced to death this week.CreditKhalid Mohammed/Associated PressA terrorism court in Baghdad where seven French citizens were sentenced to death this week.CreditKhalid Mohammed/Associated PressIf the first week was any indication, the legal process in Iraq will be swift, and unvarying.“The penalty is the death sentence, whether they fought or not,” Judge Ali said in a brief interview after court adjourned on Monday. He also sentenced an eighth defendant, a Tunisian who is a resident of France, to death.In the first batch of 12 cases that began on Sunday, France, a country that prides itself as a champion of human rights and opponent of the death penalty, essentially outsourced the judicial process to Iraq.The French foreign minister, Jean-Yves Le Drian, said Wednesday that there were 450 French citizens affiliated with the Islamic State being held in camps in northeastern Syria. But with memories still fresh of the terrorist attacks in Paris in 2015, in Nice in 2016 and Trèbes in 2018, polls show that a vast majority of French people do not want these citizens returned, even if they were to be detained and tried.One problem, said Jean-Charles Brisard, the head of the Center for the Analysis of Terrorism in Paris, is that sometimes “there’s not enough proof” to convict them in French courts.So France, which has sometimes refused to return foreigners to face justice in countries that use torture and the death penalty, has turned its citizens over to a legal system in which due process rights are significantly weaker and the death penalty is common.International legal experts say Iraq’s terrorism prosecutions are intrinsically flawed: Confessions are sometimes obtained through torture or coercion, some judges are biased, and defendants routinely lack adequate legal counsel.“You can’t outsource a trial that suspends fundamental trial rights, if the trial is unfair and the punishment is disproportionate,” said Andrew Clapham, professor of international law at the Graduate Institute for International and Development Studies in Geneva.Clockwise from top left, Salim Machou, Mustapha Merzoughi, Brahim Nejara, Leonard Lopez, Yassine Sakkam and Kevin Gonot, all French citizens, were sentenced to death this week for membership in the Islamic State.Creditvia Agence France-Presse — Getty ImagesImageClockwise from top left, Salim Machou, Mustapha Merzoughi, Brahim Nejara, Leonard Lopez, Yassine Sakkam and Kevin Gonot, all French citizens, were sentenced to death this week for membership in the Islamic State.Creditvia Agence France-Presse — Getty ImagesGovernment-appointed lawyers earn just $25 for taking a terrorism case from trial to appeals. In the cases this week, one lawyer said she had not seen her client’s file until the defendant entered the courtroom; others said they had just five or 10 minutes to review the case and discuss it with their clients beforehand.Iraq’s antiterrorism law is a catchall that criminalizes membership in a terrorist organization, so the ISIS cook may face the same penalty as the bomb maker: life imprisonment or death. The law’s vagueness means that people are not held accountable for their specific crimes, human rights experts say. So if any of the defendants convicted this week committed murder, torture or rape, the subjects never arose in the trials.Iraq is keenly aware of the spotlight and outfitted a new courtroom for the occasion. A panel of three judges, in black robes with white trim, sat on a platform beneath a flat-screen TV, which featured slick videos of the allegations against each suspect set to rousing music.After Iraq’s 10-minute trials of Iraqi ISIS suspects last year, Judge Ali’s two-hour trials seemed unrushed and deliberate by comparison. He allowed the defendants and their lawyers ample time to present their cases. Sometimes he even stopped the lawyers from asking questions that could harm their clients’ defense.However, he had no compunction about invoking the death penalty. Iraq ranked in the top five countries that most frequently carried out the death penalty in 2018, according to Amnesty International. Its liberal use of capital punishment appears to violate international covenants, which Iraq has signed, that reserve the death penalty for only the most serious crimes, like murder.Some 514 foreign ISIS suspects were tried in Iraqi courts in 2018 and the first four months of 2019, according to the Supreme Judicial Council. A spokesman said the council did not have records of how many had received the death penalty or how many had been executed.If any of the defendants convicted this week committed murder, torture or rape, the subjects never arose in the trials.Suspected Islamic State fighters detained at a courthouse in Qaraqosh, Iraq, in 2017.CreditSergey Ponomarev for The New York TimesSuspected Islamic State fighters detained at a courthouse in Qaraqosh, Iraq, in 2017.CreditSergey Ponomarev for The New York TimesIraq has also been criticized by human rights advocates for sometimes allowing confessions obtained under torture to be used as evidence.One of the French defendants said he had been tortured into writing his confession. During his trial on Monday, Fodhil Tahar Aouidate, a native of Roubaix, France, lifted up his shirt and showed black marks on his stomach to the judge and then turned and showed them to the courtroom.Judge Ali adjourned Mr. Aouidate’s trial until his allegations could be evaluated by a medical team. He is to return to court on Sunday. Another defendant, Mohammed Hassan Mohammed Berriri, said Wednesday that he had seen people tortured and beaten and to avoid that, “I will say anything.”On Sunday, after death sentences were handed down in the first three cases, the French Foreign Ministry said in a statement that “France respects the Iraqi authorities’ sovereignty,” but added that “France is opposed, on principle, to the death penalty, anytime and anywhere.”Under Iraqi law, defendants have the right to appeal and the president must sign off before an execution is carried out. On Tuesday, Mr. Le Drian, the French foreign minister, said he had discussed the death-penalty issue with the Iraqi president, Barham Salih.Even if the French-Iraqi partnership is deemed a success, there are obstacles to scaling it up for the remaining 3,000 foreign detainees in Syria from about 80 countries.Several countries are in talks with the Iraqi government about transferring the detainees in Syria to Iraq for trial. Iraq is willing to handle the remaining cases but wants the suspects’ home countries to pay the costs of the court and prisons. There have been reports that Iraq is asking more than $1 million per detainee.Raqqa, Syria, was the capital of the Islamic State’s self-declared caliphate, spanning Iraq and Syria. The ISIS suspects tried in Iraq this week were captured in Syria.CreditIvor Prickett for The New York TimesRaqqa, Syria, was the capital of the Islamic State’s self-declared caliphate, spanning Iraq and Syria. The ISIS suspects tried in Iraq this week were captured in Syria.CreditIvor Prickett for The New York TimesSeveral European countries are discussing the creation of an international tribunal to try ISIS suspects, but experts consider such a body overly expensive, of limited use and unrealistic.The Kurdish authorities in northeastern Syria have suggested building a courthouse there to try foreign Islamic State prisoners but the location is in a war zone with no clear sovereignty.Jeanine Hennis Plasschaert, the United Nations special representative for Iraq, said that ultimately countries “bear primary responsibility for their own nationals, including the treatment of their citizens in accordance with international law.”“One would expect and hope that individual states take back their nationals to process, prosecute, and deradicalize them,” she said.On Monday, when Judge Ali asked Mustapha Merzoughi, 37, to explain how and why he had journeyed to Syria, the stocky Frenchman at first said nothing. Then he almost spit out his words.“I did stupid things, I regret it,” he said. “But I did not kill anyone. I did not want to commit any crime. I know I made a big mistake by joining a terrorist organization. I know you will give me the death penalty.”When the hearing was over and he had sentenced Mr. Merzoughi to death, Judge Ali was asked if the defendants’ repeated declarations of regret were taken into account.“Anyone who commits a crime will be feeling that kind of regret, but that’s not enough to drop the charges,” he said. “There are the victims, thousands of victims, Yazidis who were captured and sold at markets as slaves. Who would agree to join an organization that committed these kinds of crimes?”Correction: May 30, 2019A photo with an earlier version of this article was published in error. The building shown in the image was not the Kharkh Courthouse where the terrorism trial of seven French citizens was held. The image has been replaced.Falih Hassan contributed reporting from Baghdad.