BAGHDAD — Islamic State militants, driven from their main stronghold in northern Iraq, are trapped in a military vise that will squeeze them on both sides of the Syria-Iraq border, U.S. Defense Secretary Jim Mattis said.

Mattis arrived in the Iraqi capital Tuesday, hours after President Donald Trump outlined a fresh approach to the stalemated war in Afghanistan. Trump also has pledged to take a more aggressive, effective approach against IS in Iraq and Syria, but he has yet to announce a strategy for that conflict that differs greatly from his predecessor’s.

In Baghdad, Mattis was meeting with Iraqi government leaders and U.S. commanders. He planned to meet in Irbil with Massoud Barzani, leader of the semi-autonomous Kurdish region that has helped fight IS.

Mattis told reporters before he left neighboring Jordan that the Middle Euphrates River Valley — roughly from the western Iraqi city of al-Qaim to the eastern Syrian city of Der el-Zour — will be liberated in time, as IS takes hit from both ends of the valley that bisects Iraq and Syria.

“You see, ISIS is now caught in-between converging forces,” he said, using an alternative acronym for the militant group that burst into western and northern Iraq in 2014 from Syria and held sway for more than two years. “So ISIS’s days are certainly numbered, but it’s not over yet and it’s not going to be over any time soon.”

Mattis referred to this area as “ISIS’s last stand.”

Unlike the war in Afghanistan, Iraq offers a more positive narrative for the White House, at least for now.

Having enabled Iraqi government forces to reclaim the Islamic State’s prized possession of Mosul in July, the U.S. military effort is showing tangible progress and the Pentagon can credibly assert that momentum is on Iraq’s side.

The ranking U.S. Air Force officer in Iraq, Brig. Gen. Andrew A. Croft, said that over the past few months, IS has lost much of its ability to command and control its forces.

“It’s less coordinated than it was before,” he said. “It appears more fractured — flimsy is the word I would use.”

Brett McGurk, the U.S. special envoy to the counter-IS coalition, credits the Trump administration for having accelerated gains against the militants. He said Monday that about one-third of all territory regained in Iraq and Syria since 2014 has been retaken in the past six or seven months.

“I think that’s quite significant and partially due to the fact we’re moving faster, more effectively,” as a result of Trump’s delegation of battlefield authorities to commanders in the field, McGurk said. He said this “has really made a difference on the ground. I have seen that with my own eyes.”

It seems likely that in coming months Trump may be in position to declare a victory of sorts in Iraq as IS fighters are marginalized and they lose their claim to be running a “caliphate” inside Iraq’s borders. Syria, on the other hand, is a murkier problem, even as IS loses ground there against U.S.-supported local fighters and Russian-backed Syrian government forces.

The U.S. role in Iraq parallels Afghanistan in some ways, starting with the basic tenet of enabling local government forces to fight rather than having U.S. troops do the fighting for them. That is unlikely to change in either country.

Also, although the Taliban is the main opposition force in Afghanistan, an IS affiliate has emerged there, too. In both countries, U.S. airpower is playing an important role in support of local forces, and the Pentagon is trying to facilitate the development of potent local air forces.

In Iraq, the political outlook is clouded by the same sectarian and ethnic divisions among Sunni, Shiite and Kurdish factions that have repeatedly undercut, and sometimes reversed, security gains following the toppling of Saddam Hussein’s government in 2003.

An immediate worry is a Kurdish independence referendum to be held Sept. 25. If that’s successful, it could upset a delicate political balance in Iraq and enflame tensions with Turkey, whose own Kurdish population has fought an insurgency against the central government for decades. McGurk reiterated U.S. opposition to holding the Iraqi Kurdish referendum.

“We believe these issues should be resolved through dialogue under the constitutional framework, and that a referendum at this time would be really potentially catastrophic to the counter-ISIS campaign,” McGurk told reporters in a joint appearance with Mattis before they flew to Iraq.

With Iraqi troops on Tuesday reaching the first urban areas of the IS-held northern town of Tal Afar on the third day of an operation, Mattis has refused to predict victory. He says generals and senior officials should “just go silent” when troops are entering battle.

“I’d prefer just to let the reality come home. There’s nothing to be gained by forecasting something that’s fundamentally unpredictable,” he told reporters traveling with him.