WASHINGTON — Two hostages held by al-Qaida, including a U.S. aid worker, were accidentally killed in a U.S. drone strike in Pakistan in January, government officials disclosed Thursday, prompting President Barack Obama to offer an emotional apology and assume “full responsibility” for their deaths.

The two hostages, Warren Weinstein, an American held by al-Qaida since 2011, and Giovanni Lo Porto, an Italian held since 2012, died after the U.S. attack on a compound in Pakistan. Officials said they had no idea that the hostages were being held there despite hundreds of hours of surveillance before the strike and that they only learned afterward that the civilians were among the casualties.

Obama came to the White House briefing room shortly after a statement was issued announcing the deaths, appearing unusually affected by the tragedy. “As president and as commander in chief, I take full responsibility for all our counterterrorism operations,” the grim-faced president told reporters. “I profoundly regret what happened,” he added. “On behalf of the U.S. government, I offer our deepest apologies to the families.”

Two other Americans affiliated with al-Qaida, Ahmed Farouq and Adam Gadahn, were also killed in U.S. operations in the same region in January, the White House said in its statement. Neither had been specifically targeted and their presence at the sites of the operations was not known at the time, according to the statement. Farouq was killed in the same strike that killed the hostages while Gadahn was “likely” killed in a separate operation, the statement said.

The president did not explain why it took three months to disclose the episode but other officials, speaking on condition of anonymity to discuss secretive operations, said it took weeks to piece together what happened. Intelligence agencies picked up information soon after the January strikes that the two hostages were dead but were not immediately clear how they died. It took weeks to correlate their reported deaths with the drone strikes, the officials said, and only in the last few days was it confirmed firmly enough to bring to the president.

Efforts to reach Weinstein’s family were not immediately successful Thursday. In a written statement, his wife, Elaine Weinstein, said the family was “devastated” by the news and added that it looked forward to learning more about what happened.

“But those who took Warren captive over three years ago bear ultimate responsibility,” she wrote. “I can assure you that he would still be alive and well if they had allowed him to return home after his time abroad working to help the people of Pakistan.”

“The cowardly actions of those who took Warren captive and ultimately to the place and time of his death are not in keeping with Islam, and they will have to face their God to answer for their actions,” she added.

The issue of killing Americans through drone strikes has been an acutely sensitive one for Obama. His administration has concluded that the federal government has the right to use deadly force against Americans tied to al-Qaida if capture is not feasible. In the case of the two al-Qaida figures killed in January, no legal determination would have been needed because it was not known that they were at the bombed sites.

Some members of Congress criticized the administration or called for more oversight. “Warren Weinstein did not have to die,” said Rep. Duncan Hunter, R-Calif. “His death is further evidence of the failures in communication and coordination between government agencies tasked with recovering Americans in captivity — and the fact that he’s dead, as a result, is absolutely tragic.”

Josh Earnest, the White House press secretary, rejected Hunter’s assertions and said the strikes did not deviate from normal practice and added that the families would receive financial compensation. Obama said a full review was underway to identify any changes that should be made to avoid similar errors in the future. “We will do our utmost to ensure it is not repeated,” Obama said.

Obama did not sign off on this specific strike, aides said, because he has authorized the CIA and military to carry out drone attacks without further consultation if they fit certain criteria. In his comments, Obama said the operation that killed the two hostages was conducted “fully consistent with the guidelines” for such missions in the region. He said that it was conducted after hundreds of hours of surveillance had convinced U.S. officials that they were targeting an al-Qaida compound where no civilians were present and that “capturing these terrorists was not possible.”

The president said he had ordered the incident declassified because the families of Weinstein and Lo Porto “deserve to know the truth” about what happened. “The United States is a democracy, committed to openness in good times and in bad,” he said. “It is a cruel and bitter truth that in the fog of war generally, and our fight against terrorists specifically, that mistakes, sometimes deadly mistakes, can occur.”

Even though Obama announced that the two drone strikes had been declassified, there were limits to the White House’s transparency about the two operations. Obama did not say that the CIA had carried out the strikes, nor did he say that they occurred in Pakistan.