The Islamic State has laid improvised explosives along a major highway north of Baghdad, revealing for the first time how the militant group is seeking to defend territory it controls from counterattack, U.S. defense officials said on Thursday.

U.S. officials described Iraqi forces’ struggle to clear the explosives and advance into contested areas around the strategic Baiji oil refinery as the start of what they expect will be a years-long endeavor to break the Islamic State’s hold on a vast area across Iraq and Syria.

“We’re seeing now . . . how they defend,” a U.S. military official said. “We got a good lesson on how they attack, but how they defend — we’re getting a good lesson in now.”

Officials at the U.S. military’s Central Command said Islamic State fighters were increasingly turning to roadside and car bombs as tools to try to slow the advance of Iraqi troops, as they were along the country’s main roadway connecting the capital Baghdad to militant-held areas to the north.

Poor weather in recent days has forced Iraqi troops to stick close to the highway, increasing the danger from bombs militants had buried underground.

The Islamic State’s use of such homemade explosives harks back to the worst of the violence unleashed by the 2003 U.S. invasion of Iraq. During those years, roadside bombs were a signature weapon of insurgents, killing and maiming thousands of soldiers and civilians.

U.S. officials, speaking to reporters on the condition of anonymity because they were not authorized to publicly discuss details of U.S. operations, said U.S. and allied airstrikes have been critical in providing Iraqi troops and Kurdish fighters in northern Iraq an opening to hit back at the Islamic State. The total of U.S. and allied sorties over Iraq and Syria reached 6,600 this week.

“We’re going to start to get a good lesson in how they lose, because how they morph when they lose is important,” the official said.

On Thursday, U.S. war planes conducted another strike south of Baiji, an example of how the Obama administration hopes to help Iraqi forces reverse the Islamic State’s advance without inserting American soldiers into another ground war in Iraq.

The strikes have been necessary in part to compensate for weaknesses in Iraq’s military, which were exposed when Iraqi troops abandoned their posts in droves this summer in the face of an Islamic State assault.

But U.S. officials said that Iraqi troops’ attempts to recapture strategic points north of Baghdad, like their struggles to reclaim other militant-held parts of the country, amount to little more than localized attacks, not the kind of major offensive required to defeat the Islamic State.

“I would not say that the Iraqi army is broadly on the ­counter-offensive,” a second military official said. “But they have been able to conduct localized counter-attacks and spoiler ­attacks to contest the advance of ISIL,” he said, using another name for the group.

Building that large-scale offensive capability will require long-term support to Iraqi forces, officials said, including reforms to Iraq’s security forces and ministries. While the United States spent over $20 billion training and equipping Iraqi forces from 2003 to 2011, the Pentagon has blamed former prime minister Nouri al-Maliki for allowing his military leadership to decay after the U.S. withdrawal in 2011.

Officials cautioned it could take many months before Iraqi forces were ready to attempt a recovery of important areas such as Mosul, a major northern city that is comfortably in Islamic State hands, or contested Anbar province in western Iraq. Equally important for Iraq’s new Shiite-led government would be building support among the country’s skeptical Sunni population, the officials said.

But an effort to enlist Sunni tribesmen to fight the Islamic State, similar to the tribal movement that occurred in western Iraq during the last U.S. conflict there, appears to be moving slowly.

Even after weeks of airstrikes and a growing U.S. military mission on the ground, the second official said, the overall campaign is only at “the first couple of minutes of the first quarter.”