An honor guard carries the coffin of U.S. Army Sergeant La David Johnson, who was among four Special Forces soldiers killed in Niger, at a graveside service in Hollywood, Florida, on Oct. 21. (Joe Skipper/Reuters)

The four U.S. soldiers killed last month in an ambush were helping track and fight Islamist militants along the Mali-Niger border in the hours before their death, according to the nation's defense minister and a wounded Nigerien soldier who survived the attack.

The accounts raise questions about the Pentagon's assertions that the American and Nigerien troops were on a low-risk reconnaissance mission and that chances of contact with militants were unlikely. They were, instead, operating in a dangerous and complex battle zone, where attacks happen frequently. U.S. troops are in Niger to train and advise, military officials have said, not to engage in combat missions.

Questions still unanswered: Was the team operating on faulty intelligence? Or was the mission changed at the last minute?

The details suggest revenge may have been a motive for the militants — who were part of a relatively new Islamic State affiliate, the Pentagon suspects — in their attack on 11 U.S. soldiers and 30 Nigerien troops.

In a 90-minute phone interview, the wounded Nigerien soldier described the surprise assault on Oct. 4 after they left the border village of Tongo Tongo. Five Nigerien soldiers also died.

The U.S. troops, who included elite Green Berets, wound up taking the lead in the intense firefight. Some Nigerien soldiers fled, even as the Americans ordered them to stay on and fight.

"The Americans had more sophisticated weapons and so we let them confront the enemy while we took cover," said Sgt. Abdou Kané, 28, who was shot in the leg and who spoke from the town of Agadez in central Niger. "The Americans were telling us not to flee but to go back and fight the enemy. But the enemy was following us and shooting at us."

The insurgents, he said, far outnumbered the U.S.-Nigerien team and had much greater firepower, including pickup trucks mounted with heavy machine guns.

The ambush, by masked and turban-wearing fighters, was so well-planned they had sent a large herd of cows toward the team, then attacked under cover of the dust raised by the cattle.

In the chaos, he added, several of the Americans were separated from the main group, as the team split up to avoid the militants. Air support to help the besieged team and evacuate the wounded took an hour or more to arrive.

A person at the military hospital in the capital, where Kané was treated for his injury, provided his number to The Washington Post.

The accounts suggest U.S. troops may have gone beyond the scope of their mission in Niger, and they raise a question as to whether they had the required authorization to capture or kill militants. The Pentagon has said it is investigating whether the soldiers' stated mission had changed.

At the very least, the accounts underscore the perils faced by U.S. Special Forces and other American troops even in their capacities as trainers and advisers.

Niger's defense minister, Kalla Moutari, blamed a failure in intelligence, which resulted in a miscalculation of the risk of engaging with militants in the area around Tongo Tongo. But he also said the team had managed to kill some militants in a counterterrorism operation before they arrived in the village.

"It was a mission to collect information and to neutralize the enemy or the threat," Moutari said in an interview. "The intelligence wasn't as complete as we thought, but at the same time some terrorists were neutralized on the way back from the mission.

"It so happened that the enemy had time to take position and got the right opportunity to attack them."

The American soldiers, Kané said, did not fight in the operation before arriving in Tongo Tongo but rather were advising the Nigerien forces.

Several Defense Department officials contacted for comment Sunday either did not respond or declined to do so.

"We are all waiting for the investigation to conclude," said Navy Capt. Jason Salata, a spokesman for U.S. Special Operations Command.

In the days since the ambush, conflicting accounts have emerged. Some reports have suggested the U.S.-Nigerien team had been reassigned to back up another team in a separate counterterrorism operation. When asked if his team had changed missions, Kané declined to discuss the military's operational procedures.

"The mission was to go to Mali to capture the terrorists and bring them back," Kané said.

Special Forces soldiers make up about a third of the roughly 800 American service members in Niger. Several hundred troops work on a drone base in the capital, as well as preparing for a second drone base in Agadez. The Special Forces' mission is to "advise and assist" Nigerien soldiers in counterterrorism operations.

Several radical Islamist groups linked to both the Islamic State and al-Qaeda operate along the vast and ungoverned Mali-Niger border. Since February 2016, there have been at least 46 attacks, mostly targeting local security forces, according to the United Nations. Since the Oct. 4 ambush, there have been several more assaults by militants, including one in which 13 Nigerien gendarmes were killed on Oct. 21.

The Niger government has deemed the terrain around Tongo Tongo so insecure that it imposed a state of emergency in several districts.

On Oct. 3, Kané's team was along the border, crossing in and out of Mali. They were traveling in six pickup trucks — none with mounted machine guns, Kané said. The Americans were in armored ones, but the Nigeriens were not. The soldiers were carrying only light weapons.

There had been more than two dozen joint missions like this along the border in the past six months without incident, according to U.S. and Nigerien officials. Moutari said the team was properly armed because "the capability to move fast" was essential when chasing militants.

The Americans had night vision binoculars, and they helped the Nigeriens attack a small band of militants that night, Kané said, adding that he was trained by the Americans.

Some fighters, he said, were captured, but he declined to say what happened to them. Nor would he discuss which extremist group they had targeted. "If there was no way to capture them, we had to kill them," Kané said.

After spending the night on the border, they headed back. On the way, they stopped in Tongo Tongo to pick up water. It was around 11 a.m. The villagers brought a pail to fetch water from a well.

As they waited, the village chief approached the Americans. He asked for their help in getting medicine to treat some sick children. The Nigerien soldiers, meanwhile, cooked breakfast, Kané recalled. About 40 minutes later, the chief gave them directions to their base, about two hours away.

They headed out of Tongo Tongo.

About 100 yards outside the village, in an isolated patch surrounded by bushes, they heard three gunshots, Kané said. The convoy stopped. The American vehicles went forward, he said. There were more gunshots, and they returned fire.

That's when the militants sent the herd of cattle toward them, Kané said, generating large clouds of dust. "The enemy could see us, but we couldn't see the enemy," he said. The fighters, numbering more than 50, were using heavy machine guns, rocket-propelled grenades and Kalashnikov rifles.

Some were dressed in black. Others were yelling "Allahu akbar" — God is great.

"They had more sophisticated weapons than us," Kané said.

As the militants intensified their attacks, the soldiers retreated and scattered in different directions. Some were forced to abandon their trucks. "We all decided to go our own way to disrupt the enemy," Kané said.

The Americans, along with a few Nigerien soldiers, he said, continued to engage the militants. Kané was hurt when a bullet went through his thigh. At some point — he doesn't know when — he saw an American soldier calling for support on his radio.

When French Mirage jets and rescue helicopters arrived, the militants fled. The helicopters didn't land until Nigerien ground reinforcements secured the area. Then, Kané, along with two wounded Americans and another wounded Nigerien soldier, were flown to the capital for medical care.

There were no remains of U.S. soldiers in the helicopter. A few hours later, the bodies of three — Staff Sgts. Bryan Black, Jeremiah Johnson and Dustin Wright — were retrieved. Two days later, Nigerien forces found the remains of Sgt. La David Johnson, a mile away from the ambush site.

"We tried our best, but the enemy had everything they needed to beat us," Kané said.

Dan Lamothe in Washington contributed to this report.