President Obama phoned the president of Pakistan on Sunday to offer “condolences” for the deaths of two dozen soldiers killed in NATO airstrikes along the Afghan border, the White House said.

The conversation, eight days after the attack, overcame the reservations of some Defense Department officials and favored an approach suggested by diplomats who had urged a conciliatory gesture to try to repair the strained alliance between the two countries.

But Mr. Obama’s comments to President Asif Ali Zardari stopped short of a formal apology or a videotaped statement to ease the public anger in Pakistan.

“The president made clear that this regrettable incident was not a deliberate attack on Pakistan and reiterated the United States’ strong commitment to a full investigation,” the White House said in a statement. “The two presidents reaffirmed their commitment to the U.S.-Pakistan bilateral relationship, which is critical to the security of both nations, and they agreed to stay in close touch.”