Afghan security forces stand guard after an attack on the American University of Afghanistan in Kabul on Aug. 25. (Rahmat Gul/AP)

U.S. Special Operations forces conducted a secret raid last month to rescue Western hostages in Afghanistan but failed to recover the men, the Pentagon said Thursday.

Pentagon press secretary Peter Cook said President Obama, acting on a recommendation from Defense Secretary Ashton B. Carter, authorized the August mission to rescue the two civilian hostages in an unspecified area of Afghanistan.

U.S. officials thought the hostages, an American and Australian who were professors at the American University in Kabul and were seized at gunpoint in early August, were being held in eastern Afghanistan by the Haqqani network, a hard-line Taliban faction.

During the raid, a team of Navy SEALs touched down under the cover of night at a compound where the hostages were thought to be held. The hostages were not there, but a group of militants was, leading to a firefight in which seven militants were killed, officials said. No Americans were wounded.

“Military hostage rescue operations are inherently sensitive and dangerous, and careful deliberation went into this mission,” Cook said in a statement. “The United States military remains fully prepared to take extraordinary steps to protect American citizens anywhere in the world.”

The attempt to rescue the kidnapped professors, American Kevin King and Australian national Timothy Weeks, was first reported by Fox News. Officials declined to say whether they know the current whereabouts of the hostages.

It was the SEAL team’s second attempt in two days to recover the men. A night earlier, the elite forces had boarded their aircraft and flown toward their target even before their mission had secured presidential approval, officials said. They were forced to turn back because the proposal for the raid had not reached the White House with sufficient time for it to be reviewed and presented to Obama for approval.

“There was a very narrow window before the sun came up,” said a defense official who like others interviewed spoke on the condition of anonymity because he was not authorized to speak on the record.

By the next night, Obama’s most senior advisers had studied the plan, assessing the intelligence about the hostages’ whereabouts and the risks to American personnel. The president signed off on it, meaning the nighttime raid could go forward.

“The president authorized this mission when it was presented to him, with the careful review and recommendation of his national-security team, soon after the Pentagon submitted their request,” a senior administration official said.

Some officials stressed the unusual nature of the SEALs’ step in initiating the raid the first night without having the required approval beforehand.

Officials also said there was disagreement among intelligence experts about whether the hostages had been at the compound the first night and possibly moved before the raid occurred on the second night, or whether they were never there.

The administration was also scrambling to inform the families of the abducted men even as they coordinated with the Afghan and Australian governments in responding to the disappearance.

The raid took place as a reduced U.S. military force seeks to help Afghan troops confront a resurgent Taliban. While the Obama administration declared an end to combat operations in 2014 and Western nations have pulled out most of their troops, militants continue to threaten the government, this week launching an offensive to capture a provincial capital.

Militants have also struck Western targets in the Afghan capital repeatedly, including restaurants, embassies and aid organizations. Several weeks after the professors’ kidnapping, militants attacked the American University in a prolonged assault.

It is not the first time the U.S. military has attempted to rescue Western hostages in Afghanistan. A Navy SEAL won a Medal of Honor for his role in the 2012 operation to rescue an American doctor kidnapped in eastern Afghanistan. In 2010, a British aid worker was accidentally killed by U.S. forces during a rescue attempt in eastern Afghanistan.