ISLAMABAD — Afghanistan officials claimed Sunday that Afghan and NATO forces were retaliating for gunfire from two Pakistani army bases when they called in airstrikes that killed 24 Pakistani soldiers, adding a layer of complexity to an episode that has further strained Pakistan’s ties with the United States.

The account challenged Pakistan’s claim that the strikes were unprovoked.

Saturday’s attack near the Afghan-Pakistani border was the worst to date for the two supposed allies and added tension to the U.S.-Pakistani relationship, which has been under pressure since the  U.S. raid inside Pakistan that killed Osama bin Laden in May.

Pakistan has closed its western border to trucks delivering supplies to coalition troops in Afghanistan, demanded that the U.S. abandon an air base inside Pakistan and said it will review its cooperation with the U.S. and NATO.

In a phone call Sunday to Secretary of State Hillary Rodham Clinton, Pakistani Foreign Minister Hina Rabbani Khar said her office was now undecided about attending next month’s international Bonn conference, which is supposed to plan for Afghanistan’s future.

A total breakdown in the relationship between the United States and Pakistan is considered unlikely. Pakistan relies on billions of dollars in American aid, and the U.S. needs Pakistan to push Afghan insurgents to participate in peace talks.

Afghanistan’s assertions about the attack muddy the efforts to determine what happened. The Afghan officials, who spoke on condition of anonymity because of the sensitivity of the issue, said it was unclear who fired on Afghan and NATO forces, which were conducting a joint operation before dawn Saturday.

They said the fire came from the direction of the two Pakistani army posts along the border that were later hit in the airstrikes.

NATO has said it is investigating, but it has not questioned the Pakistani claim that 24 soldiers were killed. All airstrikes are approved at a higher command level than the troops on the ground.

Secretary-General Anders Fogh Rasmussen offered his deepest condolences and said the coalition was committed to working with Pakistan to “avoid such tragedies in the future.”

“We have a joint interest in the fight against cross-border terrorism and in ensuring that Afghanistan does not once again become a safe haven for terrorists,” he said in Brussels.

NATO officials have said that insurgents fire from across the poorly defined frontier, often from positions close to Pakistani soldiers, who have been accused of supporting them.

The U.S. plans its own inquiry. Two U.S. senators Sunday urged a harder line on Pakistan.

Sen. Jon Kyl, R-Ariz., said Pakistan must understand that American aid depends on Pakistani cooperation. Sen. Dick Durbin, D-Ill., said Pakistan’s moves to punish coalition forces for the airstrikes are more evidence that the U.S. should get its troops out of the region.

On Sunday, Pakistani soldiers received the coffins of the victims from army helicopters and prayed over them. Television images showed 24 coffins laid out on a lawn, each wrapped in a green and white Parkistan flag. Each coffin was carried away by an honor guard to be buried in the soldiers’ hometowns.

The army chief, Gen. Ashfaq Kayani, attended the funerals at a military base in Peshawar.

“The attack was unprovoked and indiscriminate,” said army spokesman Maj. Gen. Athar Abbas. “There was no reason for it. Map references of all our border posts have been passed to NATO a number of times.”

There were several protests around Pakistan. In Karachi, about 500 Islamists rallied outside the U.S. Consulate.

The relationship between the United States and Pakistan, a nuclear-armed nation in a strategically vital part of the world, grew more difficult after the covert raid that killed bin Laden.

Pakistani leaders were outraged that they were not told beforehand. Also, the U.S. has been frustrated by Pakistan’s refusal to target militants using its territory to stage attacks on American and other NATO troops in Afghanistan.

A year ago, a U.S. helicopter attack killed two Pakistani soldiers posted on the border, and a joint investigation by the two nations found that Pakistani troops had fired first at the U.S. helicopters.

The investigation found that the shots were probably meant as warnings after the choppers passed into Pakistani airspace.

After that incident, Pakistan closed one of the two border crossings for U.S. supplies for 10 days. There was no indication of how long it would keep the border closed this time.

On Sunday, about 300 trucks carrying supplies to U.S.-led forces in Afghanistan were backed up at the Torkham border crossing in the northwest Khyber tribal area, the one closed last year, as well as at Chaman, in the southwestern Baluchistan province.

Militants inside Pakistan periodically attack the slow-moving convoys, and torched 150 trucks last year as they waited for days to enter Afghanistan.

Some drivers said paramilitary troops had been deployed to protect their convoys since the closures, but others were left without any additional protection. Even those who did receive troops did not feel safe.

“If there is an attack, what can five or six troops do?” said Niamatullah Khan, a fuel truck driver who was parked with 35 other vehicles at a restaurant about 125 miles from Chaman.

NATO uses routes through Pakistan for almost half of its shipments of non-lethal supplies for its troops in Afghanistan, including fuel, food and clothes. Critical supplies like ammunition are airlifted directly to Afghan air bases.

NATO has built a stockpile of military and other supplies that could keep operations running at their current level for several months even with the two crossings closed, said a NATO official closely involved with the Afghan war, speaking on condition of anonymity because of the sensitivity of the matter.

The drone strikes are unpopular in Pakistan, and Pakistani military and civilian leaders say publicly that the U.S. carries them out without their permission. But privately, they let them go on, and even help with targeting for some of them.

The Washington Post contributed to this report.