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 airbase 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.

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. 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 on the battlefield.

President Obama has made a formal request for congressional authority to use military force against the Islamic State, a move that critics argue could increase that risk.

Rear Adm. John Kirby, a Pentagon spokesman, estimated that between 20 and 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 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.

“At no time were U.S. troops anywhere near the fighting,” Kirby told reporters.

Local officials and tribal fighters said the attackers did not pass the base perimeter.

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 on Friday, also 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, which is also known as ISIS, ISIL and, in Arabic, Daesh. U.S. officials maintain that the militants are largely on the defensive.

The eight assailants who tried to enter the base Friday were dressed in Iraqi army fatigues, said Sulaiman al-Kubbaisi, a spokesman for Anbar’s provincial council. Three detonated their explosive belts, while the rest were shot, he said. Their bodies were brought onto the base, where DNA samples were taken, he added.

According to a statement from the council, about 1,000 Islamic State fighters launched Thursday’s attack on Baghdadi, a strategic location due to its proximity to the Ayn al-Asad base.

Major buildings in the town, including the police station and local council building, are in militant hands, according to tribal fighters and local officials.

“Baghdadi is now under Daesh control,” said Raad al-Timimi, a Defense Ministry spokesman, adding that urgent weapons supplies were being sent to the town.

Tribal leaders pleaded for assistance, saying that around 500 families accused of supporting the fight against the Islamic State were trapped in one neighborhood of the town and were at risk of being slaughtered.

On al-Bayan Radio, a station controlled by the militants, the Islamic State said it took advantage of foggy conditions that hampered coalition airstrikes to take over the police station and a military barracks, according to a transcript circulated by the SITE Intelligence Group. The group confirmed that it had targeted the base where U.S. Marines are stationed.

The U.S. military said its ground forces were not involved in the fighting in Baghdadi but that Anbar remains under “severe threat” by Islamic State fighters. In December, the Pentagon denied local news reports that U.S. forces were involved in direct combat with Islamic State fighters near the base.

While not tasked with combat, U.S. trainers in Iraq are authorized to use force in self-defense. The Authorization for the Use of Military Force, requested by Obama on Wednesday, would leave flexibility for Special Operations forces to assist local forces, the president said. It would allow the continuation of airstrikes and training programs in Iraq and Syria for the next three years but prohibit “enduring offensive ground combat operations.”

William Branigin and Craig Whitlock in Washington contributed to this report.