WASHINGTON — A U.S. military account of a NATO airstrike that killed 24 Pakistani soldiers over the weekend suggests the deaths resulted from a case of mistaken identity, The Associated Press learned Monday.

The incident was the deadliest case of friendly fire with Pakistan since the Afghanistan war began, and has sent the perpetually difficult U.S.-Pakistan relationship into a tailspin.

The AP has learned details of the raid, which began when a joint U.S.-Afghan special operations team was attacked by militants just inside Afghanistan. It ended when NATO gunships and attack helicopters fired on two encampments they thought were used by militants but were actually Pakistani border posts, the military account said.

U.S. officials say the account suggests that the Taliban may have deliberately tried to provoke a cross-border firefight that would set back fragile partnerships between U.S. and NATO forces and Pakistani soldiers at the ill-defined border.

Gen. James Mattis, head of U.S. Central Command, announced Monday that he has appointed Brig. Gen. Stephen Clark, an Air Force special operations officer, to lead the probe of the incident, and said he must include input from the NATO-led forces in Afghanistan, as well as representatives from the Afghan and Pakistani governments.

According to the U.S. military records, described to the AP on condition of anonymity, the joint U.S. and Afghan patrol requested backup after being hit by mortar and small-arms fire by Taliban militants early Saturday.

Before responding, the joint U.S.-Afghan patrol first checked with the Pakistani army, which reported it had no troops in the area, the military account said.

Some two hours later, still hunting the insurgents who had by now apparently fled in the direction of Pakistani border posts, the U.S. commander spotted what he thought was a militant encampment, with heavy weapons mounted on tripods. The exact location of the border is in dispute in several areas.

Then the joint patrol called for the airstrikes at 2:21 a.m. Pakistani time, not realizing that the encampment was apparently the Pakistani border post.

Records show the aerial response included Apache attack helicopters and an AC-130 helicopter gunship.

U.S. officials are working on the assumption the Taliban chose the location for the first attack to create just such confusion and draw U.S. and Pakistani forces into firing on each other, according to U.S. officials briefed on the operation.

The Pentagon released a four-page memo from Centcom commander Mattis to the general he named to lead the inquiry. Mattis directed Clark to determine what happened, which units were involved, which ones did or did not cross the border, how the operation was coordinated, and what caused the deaths and injuries.

Mattis asked Clark to also form any recommendations about how border operations could be improved, and he said the final report should be submitted by Dec. 23.

Key disputes being examined by U.S. military officials include the breakdown in communications, and why U.S. troops believed they were responding to insurgent fire and that there were no friendly forces in the area.