BRUSSELS — NATO’s military leaders are laying the groundwork to send thousands of additional troops to Afghanistan and Iraq to train local forces locked in fierce battles with militants. The move comes as alliance leaders shape and debate a multi-year plan to protect combat gains in those countries and eliminate safe havens where extremist groups might plan attacks against the West.

“I think what we’ll see is that NATO will continue with a fairly modest contribution in the near term and that political leadership in the coming months will discuss the potential for NATO assuming a greater responsibility in Iraq,” Joint Chiefs Chairman Gen. Joseph Dunford told reporters Wednesday after a day of meetings at the alliance’s headquarters.

Dunford said specific troop levels were not discussed during the meetings, which took place one week before NATO heads of state meet here.

“What I just want to do is try to find a way for each country to optimize the contribution they could make,” he said.

NATO leaders hope to know how many additional U.S. troops will be sent to Afghanistan by month’s end, allowing the alliance to deploy troops to meet the uptick in fighting that comes with warmer weather. U.S. President Donald Trump is expected to make a decision after next week’s overseas trip to NATO and the Middle East, National Security Advisor H.R. McMaster said last week.

At the same time, NATO generals appears to have a consensus that the alliance should take on more responsibility in Iraq.

“NATO has the organizational construct, the processes and so forth to be able to take on a mission like that and do it on an enduring basis,” Dunford said.

Many NATO nations have sent forces to battle Islamic State militants, contributing in one way or another to airstrikes, the training of local forces, or both. In February, NATO launched a counter-IED training program in Iraq. But while the fight in Afghanistan remains an alliance-led mission dubbed Operation Resolute Support, the anti-ISIS coalition in Iraq is coordinated by the U.S. military.

“[T]here is general agreement that NATO can, and should do more [in Iraq], especially by stepping up efforts in training, capacity building, institution building, exercises to increasing home capabilities, that means the kinds of activities where NATO has not only a good reputation but also a lot of expertise and experience,” Czech Gen. Petr Pavel, chairman of NATO’s Military Committee, said at a press conference after the meetings.

The alliance is waiting for Iraqi Prime Minister Haider al-Abadi to set a long-term requirement for training security forces. That decision is expected in the coming months.

“When the level of violence is driven down to the point where law enforcement and local Iraqi security forces can deal with it, presumably there will still be a mission to continue to build the capacity of Iraqi security forces,” Dunford said.

Dunford said NATO members might contribute to Operation Inherent Resolve — the formal name for the anti-ISIS campaign in Iraq — in the areas of logistics, acquisition, institutional capacity building, leadership schools and academies. But he said he does not expect the alliance to take control of the mission as in Afghanistan.

In Afghanistan, U.S. Army Gen. John Nicholson, the top NATO commander there, is about 3,000 troops short of the number he says he need. As of March, there were about 13,500 NATO troops in Afghanistan, including about 9,000 Americans.

NATO forces first deployed to Afghanistan shortly after the attacks of Sept. 11, 2001. Sixteen years later, their goal remains the same: to prevent terrorist organizations from using the country to launch attacks on the U.S. and Europe.

The military leaders could not say how long forces would be needed in Iraq or Afghanistan. Dunford did note that Afghan President Ashraf Ghani has set a goal to have 80 percent of the population secure by local forces within four years.

“[W]e know this is a long fight here. This is going to take time,” Gen. Curtis Scaparrotti, the NATO Supreme Allied Commander Europe, said at the conclusion of Wednesday’s meetings.

“It’s going to take time to build a military in Afghanistan who now has the fight but the capacity to sustain that and bring the stability that is needed to bring the Taliban to negotiation...I have confidence we can do that.”

Military leaders argue the additional troops are necessary to combat extremist groups intent on plotting attacks on the U.S., Europe, and Western interests..

“There are still … about 18 or 19 organizations [in South Asia] that have indicated a willingness, if not a capability to attack the West,” Dunford said.