BRUSSELS — U.S. allies said Tuesday that they were reducing and repositioning troops inside Iraq amid fears that Iran will retaliate for the killing of Qasem Soleimani, one of its most senior military officials, in a U.S. airstrike.

Some European diplomats expressed fears that the shifting of troops would diminish their ability to fight the Islamic State.

Militants “would be the only winners” of a full-blown war as a result of U.S.-Iran tensions, British Foreign Secretary Dominic Raab said Tuesday, singling out the Islamic State as having the most to gain.

Germany ordered 35 service members out of Iraq, according to a German military spokesman, while an international NATO training force moved more than half of its international group of 500 personnel away from the Baghdad area to safer sites inside Iraq and in neighboring countries, said a senior NATO diplomat, speaking on the condition of anonymity to discuss confidential troop movements.

NATO Secretary General Jens Stoltenberg spoke Tuesday to Iraqi Prime Minister Adel Abdul Mahdi, according to NATO spokesman Piers Cazalet.

Stoltenberg “stressed that allies remain strongly committed to the NATO mission in Iraq,” Cazalet said in a statement, adding that “NATO has temporarily suspended training activity on the ground, but is prepared to continue when the situation permits.”

NATO leads a noncombat training mission inside Iraq. Many NATO members also take part in the separate, U.S.-led coalition fighting the Islamic State. Both NATO and the U.S.-led coalition suspended their activity following the killing of Soleimani early Friday, citing safety concerns, although both groups say they want to resume their activities when they are able.

“NATO Allies remain committed to the #NATO training mission in Iraq and the fight against ISIS. We continue to support a safe & prosperous future for the Iraqi people and we look forward to resuming NATO’s on-the-ground training with Iraqi forces once the situation permits,” U.S. Ambassador to NATO Kay Bailey Hutchison said Tuesday in a tweet.

Europeans have been measured in their commentary about the death of Soleimani, a man whom most E.U. leaders viewed as a security threat. But many have been frustrated that the U.S. decision to target him is likely to inflame a conflict with Iran and could imperil other security priorities in the Middle East.

“The way they are doing it is only jeopardizing the fight against Daesh,” said a senior NATO diplomat, using another name for the Islamic State and speaking on the condition of anonymity to comment frankly about European assessments.

The diplomat expressed incredulity about some of the U.S. justifications for the killing of Soleimani.

“The notion that the Americans are calling this a de-escalating, defensive move is frankly surreal. It’s Soviet,” the diplomat said. “They think they’re reestablishing their deterrence while planning the withdrawal of their forces in Iraq.”

A second senior NATO diplomat, also speaking on the condition of anonymity to talk frankly, expressed concern that targeting a senior military leader of a ­nation-state could change the bounds of what is acceptable between countries that are not at war with each other. The diplomat drew a distinction with actions against Islamic State and other terrorist network leaders because they are not part of sovereign nations.

“This changes the rules of the game,” the diplomat said. “If you take out a senior military commander, why shouldn’t they do the same to you?”

The airstrike targeting Soleimani also killed senior Iraqi officials and led to a wave of anger in Baghdad. On Sunday, the Iraqi parliament approved a nonbinding resolution calling for the U.S. military to pull out of the country. It offered no time frame for the request.

A U.S. departure would lead to a wave of other pullouts from Iraq, since U.S. logistical support is key for the presence of most of the military deployments, even those of large nations such as France and Germany.

A total of 35 German service members in the district of Taji and in Baghdad were affected by the order to leave Iraq, which was completed by Tuesday morning. Another 110 German military members are still stationed in Irbil, the regional capital of Iraqi Kurdistan, the German military spokesman said.

The German government said it remains open to returning military personnel to Baghdad and other Iraqi bases. “In principle, we stand by the usefulness of this mission,” the military spokesman said. “The fight against the Islamic State is not over, and the many achievements we have made need to be secured. The decisive factor will now be the Iraqi government,” he said.

A Friday meeting of E.U. foreign ministers, convened on an emergency basis to discuss how to respond to the Iran threat, is expected to be a venue for airing frustrations with U.S. actions. Europeans fear that the Iran nuclear agreement, already faltering, may now be dead, with Tehran declaring Sunday that it will abide by even fewer of its commitments under the 2015 accord.

The E.U. foreign ministers will discuss whether and when to trigger the formal mechanism that would most likely lead to the reimposition of sanctions against Iran. Until recently, Europeans had hoped to ride out this year and to try to rebuild the deal if Trump is not reelected.

Noack reported from Berlin. Loveday Morris in Berlin and Quentin Ariès in Brussels contributed to this report.