WASHINGTON — The Pentagon and U.S. intelligence agencies view Islamic State as a shrinking and increasingly demoralized military force, a sharp shift from the seemingly invincible extremist army that declared an Islamist caliphate two years ago.

The revised assessment comes after surprisingly swift and relatively bloodless victories this summer near Syria’s border with Turkey and in the Sunni heartland of Iraq, two areas where Islamic State had appeared entrenched.

The rapid recapture this past week of Jarabulus, the militants’ last garrison by the Turkish border, helped close off a boundary region that was crucial for movement of recruits, supplies and money in and out of the group’s quasi-state.

It also was the latest fight to suggest the Sunni militants no longer are willing to fight to hold territory against a sustained assault. Only one fighter was reported killed in the assault led by Turkish tanks. Several hundred others apparently fled.

Partly as a result, U.S. officials have hinted that the long-delayed assault on Mosul, Islamic State’s self-declared capital in Iraq, may be launched this fall. The city of 1 million has been increasingly cut off by advancing Iraqi and Kurdish ground forces.

Michael Knights, Iraq fellow at the nonpartisan Washington Institute for Near East Policy, said taking back Mosul. along with the Syrian towns of Deir ez Zour and Raqqah, will mark the end of the caliphate.

“After the fall of those cities, (Islamic State) will be just another terror group,” he said. “They might be able to throw a couple car bombs in city centers and mount small arms attacks, but they will no longer engage in heavy fighting on a daily basis. In other words, we’ll be back to where we were in 2013.”

Despite the optimism, U.S. intelligence officials say Islamic State’s ability to inspire or organize terrorist attacks abroad is unimpaired — and may be a bigger threat as foreign sympathizers are unable to reach the cut-off caliphate.

“Despite the progress, it is our judgment that (Islamic State’s) ability to carry out terrorist attacks… has not to date been significantly diminished,” Nicholas Rasmussen, head of the National Counterterrorism Center, told the House Homeland Security Committee recently.

Militants still detonate car bombs or launch suicide attacks nightly in Baghdad. They could devolve into the kind of sectarian insurgency that turned Iraq into a slaughterhouse after the U.S.-led invasion in 2003, or into a stateless global terrorist network like al-Qaida became after 2001.

As in other insurgencies, militants may be running away from battles now to survive and fight again — at a time and place of their choosing, experts warn. They could be sent to other battles or used as suicide bombers.

Moreover, Islamic State still has vast sway. It controls half the area it seized in Iraq in 2014 and 70 percent of its territory in Syria, according to U.S. estimates, and continues to haul in millions of dollars from taxes, fees and extortion.

Current U.S. intelligence estimates say the group now fields as few as 16,000 fighters — half its army of a year or so ago, but still a potent force.

But U.S. officials point to progress two years and more than 14,000 airstrikes after President Barack Obama first ordered a bombing campaign against Islamic State targets.

“The number of fighters on the front line has diminished,” Lt. Gen. Sean MacFarland, commander of U.S. forces against Islamic State until this week, said in a teleconference from Baghdad. “They’ve diminished not only in quantity, but also in quality.

“All I know is when we go someplace, it’s easier to go there now than it was a year ago. And the enemy doesn’t put up as much of a fight.”

As an example, he said that after U.S.-backed Iraqi forces recaptured Fallujah, key to the Sunni heartland west of Baghdad, in late June, militants fled their former stronghold in a large convoy that coalition aircraft quickly spotted and destroyed.

“They kind of made themselves easy targets for us,” MacFarland said. “I don’t think they would have made that mistake a year or two ago.”

Each defeat has added pressure on the militants by cutting off routes used to move arms, supplies and reinforcements. That affects command, unit cohesion and efficiency.

“Now they have to go get somebody and bring them all the way across the desert to reconstitute somebody who gets killed fighting near Ramadi or Haditha or someplace like that,” he said. ”And there’s a good chance we’ll spot them long before they get there.”

In addition to losing the border towns of Jarabulus and Manbij in northern Syria, the militants have been routed this month in Khalidiyah and Qayyarah in western Iraq. They previously were ousted from Hit, Al Hawl and Rutbah in Iraq.

Islamic State’s overseas operations also are under siege.

Fighting raged from mid-May until this past week in Sirte, the group’s stronghold on the coast of Libya. U.S. airstrikes and British commando raids helped Libyan government forces finally retake the battered city.

Elsewhere, Boko Haram, the group’s affiliate in Nigeria, has lost territory to government troops. Islamic State branches in Egypt’s Sinai Peninsula, and in eastern Afghanistan, also have suffered sharp defeats.