WASHINGTON — An American soldier killed in an ambush in Niger with three comrades but recovered days later wasn’t captured alive by the enemy or executed at close range, The Associated Press has learned, based on the conclusion of a military investigation. It found evidence he apparently fought to the end.

Dispelling a swirl of rumors about how Sgt. La David T. Johnson, 25, of Miami Gardens, Florida, died, the report has determined that he was killed by enemy rifle and machine gun fire as he fled the attack by an offshoot of the Islamic State group about 120 miles (200 kilometers) north of Niamey, the capital of the African country. The attack took place Oct. 4; Johnson’s body was recovered two days later.

U.S. officials familiar with the findings spoke to the AP on condition of anonymity to describe details of an investigation that has not been finalized or publicly released.

A 12-member Army special forces unit was accompanying 30 Nigerien forces when they were attacked in a densely wooded area by as many as 50 militants traveling by vehicle and carrying small arms and rocket-propelled grenade launchers.

The officials familiar with the investigation said Johnson was hit as many as 18 times from a distance by a volley of machine gun rounds, and that he was returning fire as he and two Nigerien soldiers tried to escape.

All told, four U.S. soldiers and four Nigerien troops were killed in the ambush. Two U.S. and eight Nigerien troops were wounded.

The bodies of three U.S. Green Berets were located on the day of the attack, but not Johnson’s remains. The gap in time led to questions about whether Johnson was killed in the assault and not found, or if he was taken away by the enemy.

According to the officials, a medical examination concluded that Johnson was hit by fire from M-4 rifles — probably stolen by the insurgents — and Soviet-made heavy machine guns. It is believed he died in the attack.

The officials said Johnson was found under thick scrub brush where he tried to take cover. There were no indications he was shot at close range, or had been bound or taken prisoner, as several media reports have suggested.

A U.S. Africa Command began its investigation with a team headed by Army Maj. Gen. Roger Cloutier, the command’s chief of staff. The team visited locations in Niger to collect evidence and information about the attack, and will soon submit a draft of Cloutier’s report to Marine Gen. Thomas Waldhauser, head of Africa Command. Waldhauser could ask for additional information. The final report is expected to be released next month.

The officials familiar with the report’s conclusions said that during the attack, Johnson and two Nigerien soldiers tried to get to a vehicle to escape, but were unable to do so, became separated from the others and were shot as they were running for safety.

The report concluded that Johnson, who was athletic and a runner, was in the lead and got the farthest away, seeking cover in the brush. Officials said there were a number of enemy shells around Johnson, and evidence that he appeared to fight to the end. His boots and other equipment were later stolen, but he was still wearing his uniform.

As news of the ambush came out, the U.S. military sent in rescue teams to search for Johnson, not making his status public in the hope he might have gotten away and was still alive and hiding. The Pentagon only acknowledged that he was missing after his body was located two days later by local forces.

The Pentagon has declined to release details about the exact mission of the commando team. U.S. officials have previously said that the joint U.S.-Niger patrol had been asked to assist a second American commando team hunting for a senior

Islamic State member, who also had former ties to al-Qaida in the Islamic Maghreb. The team had been asked to go to a location where the insurgent had last been seen, and collect intelligence.

After completing that mission, the troops stopped in a village for a short time to get food and water, then left. The U.S. military believes someone in the village may have tipped off attackers to the presence of U.S. commandoes and

Nigerien forces in the area, setting in motion the ambush.

U.S. special operations forces have been routinely working with Niger’s forces, helping them to improve their abilities to fight extremists in the region. That effort has increased in recent years, the Pentagon said.

The three other Americans killed were Staff Sgt. Bryan C. Black, 35, of Puyallup, Washington; Staff Sgt. Jeremiah W. Johnson, 39, of Springboro, Ohio; and Staff Sgt. Dustin M. Wright, 29, of Lyons, Georgia.

Johnson’s combat death led to a political squabble between President Donald Trump and a Democratic congresswoman from Florida after Trump told Johnson’s pregnant widow in a phone call that her husband “knew what he signed up for.” Rep. Frederica Wilson was riding with Johnson’s family to meet the body and heard the call on speakerphone. The spat grew to include Trump’s chief of staff, who called Wilson an “empty barrel” making noise.