BAGHDAD — Disguised as Iraqi army soldiers, a squad of Islamic State militants attempted Friday to bomb a base in western Iraq where hundreds of U.S. troops are stationed, raising concerns about whether the Americans will be drawn into direct combat with the extremists.

Iraqi security forces supported by “surveillance assets” from the U.S.-led coalition against the Islamic State killed eight militants who tried to carry out a “direct attack” on the Ayn al-Asad air base in Iraq’s Anbar province at 7:20 a.m., the Combined Joint Task Force said in a statement. The men were would-be suicide bombers who sought to enter the base disguised as Iraqi army soldiers, said Sulaiman al-Kubbaisi, a spokesman for Anbar’s provincial council.

Three of the militants reportedly were able to set off their explosives.

The attack came a day after militants took control of most of Baghdadi, a town less than five miles from the base, where 320 U.S. service members have been training Iraqi troops and tribal fighters.

U.S. SOLDIERS NOT NEARBY

U.S. forces were “several kilometers” from the attack and were at no stage under direct threat, the statement said. Still, the targeting of a base hosting U.S. troops underscored the risk that Americans could be drawn into real engagement with the militants.

Rear Adm. John Kirby, a Pentagon spokesman, estimated that 20 to 25 Islamic State fighters carried out the attack while disguised as members of the Iraqi army. He said an initial group of “several” fighters detonated suicide vests that they were wearing under their uniforms. Kirby said that he did not know how far the Islamic State fighters were able to get but that U.S. officials believe all of them were killed during a firefight with Iraqi soldiers. He said there was no indication that the Iraqi soldiers suffered any casualties.

DEFENSIVE POSTURE

The Islamic State has used similar tactics in the past. Iraqi troops welcomed militants disguised in army uniforms onto another base in Anbar province in September in an attack that resulted in the deaths of hundreds of soldiers.

“We readily admit that al-Anbar is a contested region,” Kirby said earlier Friday in an interview on CNN. “But . . . this is a huge, sprawling base, roughly the size of Boulder, Colorado,” and it has “mini-bases inside the big base.”

Kirby said of the U.S. trainers and advisers, “there’s no question that they’re close to danger.” Even though they do not have a ground combat mission, “they have the right to defend themselves,” he said. “And should they ever feel under threat, they certainly have the right, the responsibility, the obligation to shoot back.”

The capture of Baghdadi, which remained under militant control Friday, demonstrates the continued ability of the Islamic State to stay on the attack despite coalition airstrikes and talk of a looming counteroffensive on major cities held by the group.