More than 16 years after 9/11 spurred a broad fight against terrorism, some Americans say it’s time to look at how the country is deploying its forces.

Reporting from the desert of Niger to a small town in Georgia, The New York Times reconstructed how four American soldiers lost their lives — and why they were in Africa to begin with.

KOLLO, Niger — Cut off from their unit, the tiny band of American soldiers was outnumbered and outgunned in the deserts of Niger, fighting to stay alive under a barrage of gunfire from fighters loyal to the Islamic State.

Jogging quickly at a crouch, Staff Sgt. Bryan C. Black motioned to the black S.U.V. beside him to keep moving. At the wheel, Staff Sgt. Dustin M. Wright tried to steer while leaning away from the gunfire. But the militants, wielding assault rifles and wearing dark scarves and balaclavas, kept closing in.

Sergeant Black suddenly went down. With one hand, Sergeant Wright dragged his wounded comrade to the precarious shielding of the S.U.V. and took up a defensive position, his M4 carbine braced on his shoulder.

“Black!” yelled a third American soldier, Staff Sgt. Jeremiah W. Johnson, checking for the wounds. Sergeant Black lay on his back, motionless and unresponsive.

Cornered, Sergeant Wright and Sergeant Johnson finally took off, sprinting through the desert under a hail of fire. Sergeant Johnson was hit and went down, still alive.

Niger LIBYA Sahara Niger ALGERIA Arlit MALI CHAD NIGER Sahel Tongo Tongo Niamey BURKINA FASO NIGERIA 300 miles LIBYA Sahara Niger ALGERIA Arlit MALI CHAD NIGER Sahel Tongo Tongo Niamey BURKINA FASO NIGERIA 300 miles LIBYA Niger ALGERIA Arlit NIGER MALI Tongo Tongo Niamey NIGERIA 300 miles Gulf of Guinea

At that point, Sergeant Wright stopped running. With only the thorny brush for cover, he turned and fired at the militants advancing toward his fallen friend.

These were the last minutes in the lives of three American soldiers killed on Oct. 4 during an ambush in the desert scrub of Niger that was recorded on a military helmet camera. A fourth American, Sgt. La David Johnson, who had gotten separated from the group, also died in the attack — the largest loss of American troops during combat in Africa since the 1993 “Black Hawk Down” debacle in Somalia.

The four men, along with four Nigerien soldiers and an interpreter, were killed in a conflict that few Americans knew anything about, not just the public, but also their families and even some senior American lawmakers.

The deaths set off a political storm in Washington, erupting into a bitter debate over how the families of fallen soldiers should be treated by their commander in chief. In a call with one of the families after the ambush, President Trump was accused of diminishing the loss, telling the soldier’s widow that “he knew what he signed up for.” Mr. Trump angrily disputed the claim, leading to a public feud.

But beyond the rancor, dozens of interviews with current and former officials, soldiers who survived the ambush and villagers who witnessed it point to a series of intelligence failures and strategic miscalculations that left the American soldiers far from base, in hostile territory longer than planned, with no backup or air support, on a mission they had not expected to perform.

They had set out on Oct. 3, prepared for a routine, low-risk patrol with little chance of encountering the enemy. But while they were out in the desert, American intelligence officials caught a break — the possible location of a local terrorist leader who, by some accounts, is linked to the kidnapping of an American citizen. A separate assault team was quickly assembled, ready to swoop in on the terrorist camp by helicopter. But the raid was scrapped at the last minute, and the Americans on patrol were sent in its place.

They didn’t find any militants. Instead, the militants found them. Short on water, the patrol stopped outside a village before heading back to base the next morning. Barely 200 yards from the village, the convoy came under deadly fire.

Four months later, tough questions remain unanswered about the chain of decisions that led to American Special Forces troops being overwhelmed by jihadists in a remote stretch of West Africa.

How did a group of American soldiers — who Defense Department officials insisted were in the country simply to train, advise and assist Niger’s military — suddenly get sent to search a terrorist camp, a much riskier mission than they had planned to carry out? Who ordered the mission, and why were the Americans so lightly equipped, with few heavy weapons and no bulletproof vehicles?

More broadly, the deaths have reignited a longstanding argument in Washington over the sprawling and often opaque war being fought by American troops around the world. It is a war with sometimes murky legal authority, one that began in the embers of the Sept. 11 attacks and traveled to Afghanistan and Pakistan. It was expanded to Yemen, Somalia and Libya before arriving in Niger, a place few Americans ever think of, let alone view as a threat.

The ashes of the fallen twin towers were still smoldering on Sept. 14, 2001, when Congress voted overwhelmingly, with virtually no debate, to authorize the American military to hunt down the perpetrators. It was a relatively narrow mandate, written for those specific attacks, but it has become the underpinning of an increasingly broad mission around the globe. For more than 16 years since that vote, American service members have been deployed in a war that has gradually stretched to jihadist groups that did not exist in 2001 and now operate across distant parts of the world.

The result has been an amorphous and contested war that has put Navy SEALs in Somalia and Yemen, Delta Force soldiers in Iraq, and Green Berets in Niger in harm’s way.

In Niger, the convoy that was ambushed contained both Nigerien and American soldiers. Here is a reconstruction of the attack. 30 Nigerien soldiers and one interpreter Five killed 11 American soldiers Four killed Five killed 30 Nigerien soldiers and one interpreter 11 American soldiers Four killed

The deadly ambush in October happened on a continent still largely viewed through the lens of humanitarian catastrophes — a place where most Americans are accustomed to expending dollars, not lives. A military report on what happened, which was supposed to be released in January, is still under review. Defense Secretary Jim Mattis told reporters that the investigation runs “thousands of pages.”

The fallout is already underway. A draft of the report has called for the Pentagon to scale back the number of ground missions in West Africa, and to strip commanders in the field of some authority to send troops on potentially high-risk patrols.

Perhaps even more significantly, the ambush has exposed holes in the argument that the Pentagon has made under three different administrations: that in many far-flung places, American troops are not actually engaged in combat, but just there to train, advise and assist local troops.

After the ambush, members of Congress from both parties said they knew little about the American military presence in Niger, expressing alarm.

“I didn’t know there was 1,000 troops in Niger,” Senator Lindsey Graham, Republican of South Carolina, told NBC’s “Meet the Press” two weeks after the deadly attack. (There are actually about 800 American troops in the country.)

“This is an endless war without boundaries, no limitation on time or geography,” Mr. Graham continued, adding, “We don’t know exactly where we’re at in the world militarily and what we’re doing.”

His Democratic colleagues claimed equal bewilderment. On the same episode, the Senate Democratic leader, Chuck Schumer of New York, said he had also been unaware that there were so many American troops in Niger. He called into question whether the authorization passed in the wake of Sept. 11, and other decades-old war power authorities, left the executive branch with carte blanche authority to send troops into danger without asking Congress first.

The Pentagon’s chief spokeswoman, Dana W. White, declined to comment “until the investigation is complete.”

“We have to get the investigation right,” she said.

But relatives of the fallen soldiers echoed many of the lawmakers’ concerns. Some of Sergeant Wright’s family members did not realize he was in potential danger at all. He had told his maternal grandmother he was in Africa doing “paperwork.” Some now ask who, and what, the sergeant — their sergeant — was sent to fight.

“Are we protecting the United States? Who knows?” asked Ginger Russell, one of Sergeant Wright’s aunts. “You don’t think of your military in Africa. You’re talking to people who didn’t even know how to pronounce ‘Niger.’ We had to look it up on the map to see exactly where it happened.”

A Military Family

The Wright family is well aware of how the military works. It can trace its lineage in the armed forces to the War of 1812. Sergeant Wright’s father, Arnold, had been a soldier, and his mother, Terri, had been in the military, too.

But in a family of military men and women stretching back more than 200 years, Sergeant Wright was the only one who didn’t make it home, the family says.

Now one of Sergeant Wright’s older brothers, Will, who served in the Army and was deployed to Afghanistan, is considering joining the military again. The idea pains their father.

“We’ve paid our dues,” he said.

Sergeant Wright grew up in the rural town of Santa Claus, Ga., and the towns around it. The streets have names like Rudolph Way and December Drive. At Christmas time, he played Santa Claus for his family.

Growing up, he was always trying to outdo his brother, a stellar athlete. When the boys were both playing football, he asked for his jersey number to be 46 — double the number on his brother’s back — because “he was going to be twice as good,” their father recalled.

He was not a natural star but, urged on by his father, he was a tenacious competitor and was in the starting lineup when he was a senior, the year his Bulldogs beat their rivals.

“He came out there to get in the fight every day,” said Brian Fitzgerald, who coached Sergeant Wright.

He briefly attended Georgia Southern University as a mechanical engineering major. But he came home and worked on gutters, finding the life unfulfilling. He told his best friend, Alton Bass, that he wanted to join a Special Forces unit.

“He didn’t just want to be any person,” Mr. Bass recalled. “He wanted to be something special.”

He decided to enlist in the Army in 2012, training at Fort Benning, Ga., and at Fort Bragg, N.C. His buoyant swagger helped hide a fear: he hated parachuting. But he sent his girlfriend a video from one jump. About 30 seconds into the descent, he turned the camera on himself: “And that’s how you jump out of an airplane, babe.”

Before he left for Niger last summer, Sergeant Wright took his grandmother’s hand at a going-away party and told her, “This is the girl for me, Granny, you’ll like her,” Elaine Trull, his grandmother, recalled.

A few days before the ambush — on Sept. 24, his 29th birthday — Sergeant Wright called his grandmother. She missed the call, so he left a message.

Ten days later, two soldiers came to Ms. Trull’s home around midnight. As soon as she saw them, she knew.

She still has the message that her grandson left on his birthday.

“I’m glad I missed it because he left me a voice mail that I can play over and over,” she said. “Three times in that voice mail, he said, ‘Granny, I love you.’”

A Shellshocked Capitol

Three days after Sept. 11, 2001, Representative Barbara Lee, Democrat of California, was sitting in a pew at the National Cathedral in Washington. It was raining, and the cathedral was teeming with dignitaries. Former Presidents Bill Clinton, George H. W. Bush, Jimmy Carter and Gerald R. Ford exchanged solemn handshakes. There were many hugs in the cavernous room, but little chatter. Everyone still looked shellshocked and frozen.

Ms. Lee was in the same teary, emotional state that seemed to have engulfed everyone in Washington. The cousin of her chief of staff had been on United Airlines Flight 93, the airliner that had crashed near Shanksville, Pa.

When the dean of the cathedral, the Very Rev. Nathan D. Baxter, spoke from the pulpit, Ms. Lee scribbled his words on her program.

“Let us also pray for divine wisdom, as our leaders consider the necessary actions for our national security,” the reverend said. “That as we act, we not become the evil we deplore.”

With those words, Ms. Lee said, she knew how she was going to vote on the war authorization measure before the House that night.

There was no mention of “Afghanistan,” “Osama bin Laden,” or “Al Qaeda” in the short resolution known as the Authorization for Use of Military Force, or A.U.M.F. It simply said that Congress authorizes the president to use “all necessary and appropriate force” against the nations, organizations or people that “he determines planned, authorized, committed, or aided” the terrorist attacks on Sept. 11 “to prevent any future acts of international terrorism against the United States by such nations, organizations, or persons.”

In the House chamber, “Yea” votes are registered with green lights, and “Nay” are red. Ms. Lee looked up after voting. There was only one red light — hers. Ten people didn’t vote. All the other lights were green.

Several of Ms. Lee’s colleagues, mostly women, came up to her in the cloakroom afterward, she said, urging her to change her vote. She didn’t. She was from a military family and had grown up near Fort Bliss, in El Paso. Her father, a World War II veteran in the “Buffalo Soldiers” 92nd Infantry Division of African-American troops, called her that night.

Among all the hate mail and death threats that she received in the weeks after, Ms. Lee remembered her father’s words: “I’m proud of you,” he said. “You don’t send our troops into harm’s way without knowing what you’re doing.”

In the years since the vote, there have been many debates as the war has expanded to branches of Al Qaeda that did not exist when 9/11 occurred and to new groups — like the Shabab (Somalia), Al Qaeda in the Arabian Peninsula (Yemen), the Islamic State (Iraq, Syria, Libya and numerous other countries), Boko Haram (Nigeria) and Al Qaeda in the Islamic Maghreb (Mali, Libya and other parts of northwestern Africa).

The mood in Congress has also changed since that night when the House voted in favor of the resolution. Ms. Lee has found many more colleagues in Congress with reservations. Last June, when she made another of her many attempts to repeal the 2001 war authorization, a majority of the members of the House Appropriations Committee supported her.

The committee approved Ms. Lee’s proposal, but the House Republican leadership eventually killed her amendment. The debate over the authority continued in the Senate until mid-September, only a few weeks before the ambush in Niger.

“What we have today is basically unlimited war — war anywhere, anytime, any place on the globe,” Senator Rand Paul, Republican of Kentucky, said during the debate in September. “I don’t think anyone with an ounce of intellectual honesty believes these authorizations allow current wars we fight in seven countries.”

In fact, the war authorization passed by Congress more than 16 years ago has been used so often to justify the deployment of American troops that some administrations have tried to sidestep criticism by finding other legal powers to invoke, including for American troops in Niger.

On Feb. 20, 2013, President Barack Obama sent a short letter to Representative John A. Boehner, then the speaker of the House. Citing the 1973 War Powers Act — not the 2001 war authorization, which the administration was already under fire for using too often — the president said the Pentagon would deploy 40 troops to Niger to set up a drone base, conduct reconnaissance flights and help facilitate intelligence gathering for French forces in Mali. The troops, and others to follow, would also provide training and assistance for local Nigerien forces, he said.

Now, in the aftermath of the ambush in Niger — and declarations by members of Congress that they did not know the extent of America’s involvement in the country — the debate is happening again. Many lawmakers are focusing broadly on the 2001 resolution, the overarching blanket that has been used to justify the deployment of many American troops in hot spots around the world.

Ms. Lee says she plans to try again this year.

“It’s a very dangerous slope that we’re on,” said Representative Tom Cole, Republican of Oklahoma, who sided with Ms. Lee in the Appropriations Committee but later heeded Speaker Paul D. Ryan’s request to stop it from going to a full vote until the administration could weigh in.

Mr. Cole said that American troops should be in West Africa. But, he said, America’s elected representatives should be given a chance to give the go-ahead first.

“If we’re going to have people who are in harm’s way and we know we are putting them in a dangerous situation, there ought to be a more thorough discussion of it,” Mr. Cole said.

‘Unimaginable Grief’

Staff Sgt. Bryan C. Black planned parts of his memorial service before he deployed to Niger.

It’s something that service members often do. Sergeant Black wanted his mourners to hear “Finnegans Wake,” the 19th-century Irish folk song that later inspired James Joyce’s novel.

In the song, Tim Finnegan dies from a fall. But when his mourners accidentally spill whiskey on his corpse, he revives, exclaiming, “Thunderin’ Jaysus, do you think I’m dead?”

At the memorial service in Sergeant Black’s hometown, Puyallup, Wash., one of his eulogists explained the choice: “He wanted people to have fun, even though they were feeling this heavy loss.”

The loss of Sergeant Black was felt keenly in his hometown, where he was remembered as a childhood chess whiz, collegiate wrestler and master of languages. Hans Zeiger, a Washington state senator who was a few years behind him in school, remembers being awed by his intellect.

Sergeant Black was fiercely competitive. After a chess tournament in which his brother won a trophy and he did not, he spent the entire summer after fourth grade learning how to perfect his game.

Many years later, he taught himself obscure local dialects so he could communicate with people he met on far-flung deployments in the military. He also spoke French and Arabic.

When Sergeant Black suffered a rare chess loss, he analyzed what went wrong.

“He wasn’t going to lose the same way ever again,” said Phil Watson, who grew up playing chess with him.

One of his many victories came in his senior year of high school, when he won the 2000 Washington Junior Open with a perfect score, according to Chess.com.

The same persistence was evident in wrestling, which he began in high school. Despite being dogged by heat injuries during a high school wrestling camp, he kept at it until he collapsed from heat stroke. After five days in the hospital, he went back and completed the camp, according to his family. He wrestled on the varsity team at Central Washington University, where he graduated in 2002.

“He was a scholar who could win a bar fight,” Mr. Watson said.

After college, he moved to Mammoth Lakes, Calif., and worked as a ski instructor and in construction, and met his wife, Michelle, whom he married in 2005.

Four years later, he enlisted in the Army, where his family said he found the sort of challenges he always craved, including tough physical training as well as medical studies on nights and weekends.

As he prepared to deploy to Niger, Sergeant Black told his father, Hank Black, that he loved him.

“I placed my hands on his shoulders and prayed for his safety,” Mr. Black recalled.

“That prayer was not answered,” Mr. Black would later say at the memorial service for his son. “And unimaginable grief entered our lives.”

Some family members of the fallen soldiers have chosen not to speak about it. Special Forces soldiers value being what they call “quiet professionals,” who don’t seek attention for the dangerous work they do. Before he deployed to Niger, Sgt. Jeremiah Johnson told his family that if he died, he did not want to see his name in the news, said his mother, Debbie Gannon.

“I’m going to honor his wishes,” she added in response to a request for an interview.

The Turn Toward Africa

To understand how these men got to Niger, it’s necessary to go back to Aug. 7, 1998, the day that nearly simultaneous truck bombs exploded at two American embassies in East Africa: one in Dar es Salaam, Tanzania, and the other in Nairobi, Kenya.

The attacks, which killed more than 200 people and wounded 5,000 more, thrust Osama bin Laden onto the F.B.I.’s 10 most-wanted fugitives list and started decades of coordination with Kenya to fight terrorism in East Africa.

“Those bombings were the wake-up call to say to the United States that there is a threat emerging in Africa,” said Gen. Carter Ham, a former head of the United States Africa Command.

Africa had always been more of an afterthought when it came to American military policy. Even today, the United States has 5,000 to 6,000 troops on the entire continent — compared with 40,000 in Japan, 35,000 in Germany, 25,000 in South Korea and 14,000 in Afghanistan.

But Islamist militancy has spread in many parts of Africa, and after the Sept. 11 attacks, the United States doubled down on its counterterrorism strategy on the continent. The Bush administration expanded its presence through new basing agreements and training exercises. The Pentagon moved to build military ties with allies like Morocco and Tunisia, and sought to gain long-term access to countries like Mali and Algeria.

More than 1,800 service members were stationed in Djibouti, in the Horn of Africa, to conduct counterterrorism operations. Within a few years, that had grown to 4,000 American military personnel and civilian contractors, making it the Pentagon’s only permanent base on the continent.

By the end of the Bush administration, American Green Berets were training African armies to guard against infiltration by Qaeda militants. And within the first year of the Obama administration, a string of killings, bombings, kidnappings and other attacks against Westerners and security forces in North and West Africa raised fears that Al Qaeda’s branch in the region, Al Qaeda in the Islamic Maghreb, was taking a deadly turn, posing a larger security threat.

But by early 2013, many of the Obama administration’s ambitious counterterrorism initiatives in Africa lay in tatters. As Islamist insurgents swept through the Malian desert, some commanders of that nation’s elite army units — the fruit of years of careful American training — defected when they were needed most, taking troops, guns, trucks and their skills to the enemy in the heat of battle.

Then an American-trained officer overthrew Mali’s elected government, setting the stage for more than half of the country to fall into the hands of Islamist extremists.

France, the former colonial power, eventually intervened. It struck deep inside Islamist strongholds in northern Mali, blunting an Islamist advance and dispersing the militants, who had created one of the largest havens for jihadists in the world.

That’s when President Obama informed Congress that he was sending troops to Niger to help French forces and train local soldiers.

The threats continued spreading. Militants attacked a gas plant in Algeria in early 2013, killing 40 people from 10 countries, including the United States. Later that year, the Shabab attacked a shopping mall in Kenya’s capital, killing at least 67 people.

A month after, American commandos carried out dual raids in Africa, capturing a militant in Libya who had been indicted for his role in the 1998 East Africa embassy bombings, and clashing with the Shabab in Somalia in retaliation for the mall attack.

Mr. Obama, at a news conference three days after the raids, declared Africa a place “that you’re seeing some of these groups gather.”

“And we’re going to have to continue to go after them,” he added.

But Mr. Obama also pursued another counterterrorism strategy: relying more on allied or local troops, with a limited American combat role.

Militants kept attacking, striking the Radisson Blu hotel in Mali in 2015, the Splendid Hotel in Burkina Faso in 2016 and a beach resort in Ivory Coast in 2016. Westerners, including Americans, were killed. The United States responded by training African militaries, hoping to get them to fight back without committing American troops to another big war, like in Iraq or Afghanistan.

By the time President Trump took office in 2017, administration officials showed few signs of backing away from Mr. Obama’s overall strategy in Africa. But the Trump administration stepped up drone strikes in Somalia, and the Pentagon presented the White House with a plan that envisioned at least two more years of combat against Islamist militants there.

The plan for Somalia includes new rules quietly signed by Mr. Trump last fall for counterterrorism operations outside of conventional war zones. Mr. Trump removed several limits that Mr. Obama had imposed in 2013 on drone strikes and commando raids, loosening vetting requirements before offensive strikes and dropping assessments that every person targeted poses a specific threat to Americans.

While the American counterterrorism efforts in Libya and Somalia drew more attention, Niger had become a place increasingly surrounded by jihadist threats.

Brian McKeon, a former top Pentagon official, recalled visiting Niamey, Niger’s capital, in 2015. Military briefers offered him a sobering assessment: The Islamic State threatened from the north, Al Qaeda from the west and Boko Haram from the south and southeast.

Niger, with American help, was trying to cope with the cascade of threats. “The Nigeriens were doing a hell of a lot with not very much,” Mr. McKeon said.

The United States military presence in Niger grew from about 100 personnel in 2013 to about 800 troops now. Five years ago, Niger’s government would not have been able to send military patrols outside the capital, said J. Peter Pham, director of the Atlantic Council’s Africa Center. That has changed.

“Increasingly, their military patrols are up and along their borders,” said Mr. Pham. “It’s a good thing they’re out there in risky settings. But the downside is, the risks to U.S. forces with them increase.”

Out Too Long

Listen to ‘The Daily’: An Endless War

The Pentagon’s explanation of what happened to its soldiers in Niger has shifted repeatedly.

Within hours of the attack, Defense Department officials said the American ground patrol had been ambushed during a routine reconnaissance mission in which it was simply advising and assisting Nigerien troops.

Weeks later, American officials began privately acknowledging that the ambushed soldiers had been diverted from their low-risk patrol and sent several hours away, toward the border with Mali. The change in plans was completely unexpected, and came as the soldiers were already on their way back to base.

But an opportunity had suddenly presented itself, American and Nigerien officials now say. Just hours before, American intelligence officials had intercepted a call on an electronic device associated with Doundoun Cheffou, a former cattle herder believed to be a senior lieutenant in a shadowy local group that had recently pledged allegiance to the Islamic State.

Mr. Cheffou’s men were believed by Nigerien and some American officials to have played a role in the kidnapping of the only American to be abducted by jihadists in the region: Jeffery Woodke, an aid worker yanked out of his home in 2016 in Niger, some 300 miles from the spot where the electronic device was turned on.

If captured, Mr. Cheffou, code-named Naylor Road by the military, could lead American forces to Mr. Woodke, said Rudy Atallah, the former director of African counterterrorism policy for the Pentagon.

For more than two years, Mr. Cheffou’s group had carried out attacks on Nigerien troops, only to rush back across the border to Mali, taking refuge in a wooded, no-man’s land. French security officials say the Islamic State branch has 40 to 60 core members, but is often joined by sympathetic villagers.

American officials rushed to get a surveillance aircraft over the spot of scrubland in southwestern Niger from where the signal had emanated, one American official said. Mr. Cheffou was a “TST,” in military parlance — a time-sensitive target. Getting there quickly was crucial.

“Doundoun is a terrorist, who is recognized as a leader of the group who conducts operations in the border area,” said Niger’s minister of defense, Kalla Moutari. “We had intelligence confirming the presence of this terrorist,” he added, noting that, “on the basis of this information, action was taken.”

Military officials quickly ordered up an assault team of American, French and Nigerien commandos based in Arlit, 700 miles northeast of the capital, to go after Mr. Cheffou, officials say — part of a broader counterterrorism mission named Obsidian Nomad.

The Nigerien forces at Arlit were specially trained and equipped by the Pentagon for counterterrorism operations like this one. They were accompanied by American Special Forces advisers who had arrived in the country roughly a month before, officials say.

It is not clear how many Americans and Nigeriens were assigned to the helicopter assault mission, or who approved the operation. Such raids have been conducted in Somalia, but the tactic was unusual for the American military in West Africa. Senior American officers who have served in West Africa say it probably would have required Gen. Thomas D. Waldhauser, the head of the military’s Africa Command, in Stuttgart, Germany, to approve such a high-level mission.

The scramble to pull together a raid and hunt down Mr. Cheffou upended what had been a fairly uneventful day for the four American sergeants already out on patrol.

They were part of a group of 11 American and 30 Nigerien soldiers with a very different assignment: to visit a number of villages to meet with residents and leaders. It was considered routine, low risk and something they were well equipped for.

Their convoy was composed of eight vehicles: two pickup trucks and a sport utility vehicle for the Americans, and five trucks for the Nigeriens. Most had medium machine guns, capable of being fired by standing and aiming from the bed of the truck. The unit’s vehicles, the only ones assigned for the deployment, were lightly protected but relatively low profile. They could quickly travel overland on missions that were less dangerous than those in Iraq and Afghanistan.

Their weapons were similarly configured. The Americans in the group — an Army Special Forces team called Operational Detachment-Alpha Team 3212 — had been operating in Niger for a little over a month. Most of the team carried M4 carbines, with sights and suppressors for their rifles, according to the video footage. At least one soldier had a single-shot grenade launcher.

For visiting local villages in an area that was supposed to have little militant presence, the team’s weapons and vehicles made sense. But if attacked by a larger, more aggressive force, Team 3212’s members would barely have enough rifles and machine guns to defend themselves.

And their trucks, lightly protected with open beds, would leave any passengers inside exposed to enemy fire. Soldiers traveling in the lone S.U.V. could also wind up dangerously confined — with little ability to shoot back — inside the vehicle.

Starting around 6 a.m. on Oct. 3, the Americans and their Nigerien counterparts headed out from their base in Ouallam, 60 miles north of Niamey, to villages to meet with community leaders, according to two of the Nigerien soldiers on the mission. In the afternoon, their assignment completed, they began to head back to base.

Before they got there, a new order came in: provide backup to the assault mission gearing up in Arlit. The plan was not for Team 3212 to join the raid, officials say, but to get close enough to pursue escaping militants or help out as needed.

So, without warning, the Army soldiers out on a daylong patrol with their Nigerien trainees were turned around, pushing deeper into potentially hostile territory, lightly equipped for a new mission that exposed them to risks their commanders did not anticipate.

It is not clear who gave the order for Team 3212’s new mission. Officers who have served in the region say such a change would require approval and tasking from at least several higher levels — most likely starting with a major in Niamey and a lieutenant colonel in Chad; a task force commander stationed in Germany; and possibly a two-star general overseeing all special forces operations in Africa, also from Germany, where the United States Africa Command is based.

But soon, the plans changed yet again. Back in Arlit, the preparations for the raid were falling apart. Bad weather or mechanical problems scotched the assault team’s helicopter mission, and American spy agencies determined that Mr. Cheffou and a handful of fighters had left the location, officials say. They believed the trail had gone cold.

Still, Team 3212 and the 30 Nigeriens with it were moving into position to back up a raid that was no longer happening, officials said. The same chain of command ordered the team to press on — now on its third assignment in 24 hours. Could the team salvage some of the mission by searching the site where Mr. Cheffou had been, collecting any scraps of information left behind that might offer clues about his hide-outs and network?

By this point, current and former military officers and counterterrorism specialists say the team and its chain of command had made some crucial mistakes that would come back to haunt the soldiers.

First, the superiors who redirected Team 3212 failed to take note of the increasingly hazardous environment in the border area between Mali and Niger — an area where the United Nations had counted at least 46 attacks in the 20 months before the ambush.

But the American Special Forces had faced virtually no enemy contact during months of patrols in the region, Pentagon officials said. The Nigerien troops who set out alongside the Americans had been to the area where the ambush occurred a total of 19 times without incident, said Brig. Gen. Mahamadou Abou Tarka, a senior Nigerien officer.

This led to a general complacency, and a false sense of safety, which took root both in the rank-and-file members of the unit and in their commanders, American and Nigerien officials said. Although the Americans in Team 3212 were well trained, they were new to Niger, and some of the soldiers were on their first tour. They were accompanied by Nigerien troops, who are classified as special forces but are, in fact, their trainees.

The sense of urgency and risk that infused the planning around the raid from Arlit seemed to recede once that mission was scrubbed and Mr. Cheffou vanished — even though he and his fighters may have remained in the area Team 3212 was entering.

As the team pushed on toward the location, running on a set of plans hastily put together, the air support assigned to the raid dropped off. French forces that had been alerted to stand by to support the impending operation also stood down. The team, assigned to support a priority mission, was on its own, current and former American military officials say.

Raids are typically carried out between the hours of midnight and 5 a.m., when darkness allows troops to take advantage of one of the tools Americans have at their disposal: Night-vision devices.

Tongo Tongo MALI Akabar Bissao Tiloa Tongo Tongo NIGER Mangaize Dakala 20 miles MALI Akabar Tiloa Tongo Tongo Bani Bangou NIGER Soumat Mangaize Tibili 20 miles MALI Akabar Tiloa Tongo Tongo Bani Bangou NIGER Soumat Mangaize Tibili 20 miles

Even though the mission was scrubbed, Team 3212 apparently stuck to the same schedule. The Americans and Nigeriens bedded down in sleeping bags next to their vehicles, according to one of the Nigerien soldiers. They rose while it was still dark and pushed through to the militant campsite, hidden under a canopy of trees and set back in the rocks just shy of the Mali border.

It was empty, the two Nigerien soldiers said. But someone had been there recently: They found tea, sugar and flour, and an abandoned motorcycle. The tracks in the sand indicated that other motorcycles had sped away. They also found signs of weapons, including 14.5-mm rounds that are fired by antiaircraft weapons capable of heavily damaging most lightly armored vehicles. A case of 12.7-mm heavy machine gun bullets was also found, one Nigerien soldier said.

The team gathered material from the campsite and began the long drive back to base as the sun was rising. They had traveled no more than 20 miles of the approximately 110-mile journey back when they approached the first village on their route, a speck on the map known as Tongo Tongo.

They were tired and out of water, said one of the Nigerien soldiers who survived. They decided to take a break just outside the village, near a well. A group of villagers approached them, and one offered to run to the village to get them the bucket. He returned sometime later, and they filled their bottles with water.

It is unclear who approved the pit stop. But whatever the reason, the delay — in a location close to Mr. Cheffou’s campsite — made the team more vulnerable with each passing moment in unfamiliar territory. The team had been out for more than a day, pushing through the desert in easy-to-spot vehicles, giving the militants and their web of spotters time to plan an ambush.

The village chief walked out to meet the convoy, explaining that several children were sick. The unit began distributing medicine, the Nigerien soldiers said. Some of the soldiers saw men speeding out of the village on motorbikes, they said, possibly to alert the militants.

“How did the terrorists know that the white people were in our village giving out medicine?” said Boubacar Hassane, 45, a villager who was hoeing his millet field outside of the village that day.

Some soldiers had the impression that the chief was trying to delay them. He was later arrested, and his phone contained the numbers for known terrorists, including one connected to Mr. Cheffou, Nigerien officials said.

Around 11:30 a.m., the patrol left for home. But right outside the village, the convoy came under attack from militants with small arms, machine guns and rocket-propelled grenades.

Early in the firefight, Team 3212’s leader, Capt. Michael Perozeni, and a radio operator, Sgt. First Class Brent Bartels, were both shot and wounded, probably reducing the team’s ability to communicate to higher command, a military official said.

In the first radio transmission, the Americans said that Team 3212 was in enemy contact, according to military officials. But they did not call for help for another hour. It’s unclear why. For troops in Niger, radio communications are often plagued by distance and terrain. Whatever the reason, the team was unable to talk with French air support and had to communicate through officers in Niamey, according to a draft report of the investigation.

Tillabéri region TONGO TONGO Direction of incoming fire 500 feet AMBUSH SITE TONGO TONGO Direction of incoming fire 500 feet AMBUSH SITE TONGO TONGO Direction of incoming fire 500 feet AMBUSH SITE TONGO TONGO Direction of incoming fire 500 feet AMBUSH SITE Satellite photograph taken on Oct. 10, 2017, by DigitalGlobe, via TerraServer.

At some point, the convoy split up, leaving at least two of the vehicles cut off under heavy gunfire. Sgt. Jeremiah Johnson, Sergeant Wright and Sergeant Black were in the black S.U.V.

Somehow, it was left behind.

Roughly two hours after the ambush began, the first sign of air support arrived. French Mirage jets flew in low and fast. Behind them came French helicopters with American Special Forces stationed in Mali. The helicopters evacuated the American wounded and the other members of the team who made it to the landing zone.

The Pentagon has long asserted that the Americans killed were not left behind, and that teams of Nigerien and French forces were in the area immediately, looking for them.

The video of the ambush suggests otherwise. At least two of the dead American soldiers were shown stripped of their equipment and photographed by the Islamic State militants at close range. For a period of time, American troops were in the hands of their enemy.

That night, the American Special Forces unit from Arlit arrived in helicopters run by a civilian contracting company and recovered the bodies of Sergeant Wright, Sergeant Black and Sgt. Jeremiah Johnson.

It wasn’t until Oct. 6 that locals found the body of Sgt. La David Johnson.

The President Calls

Twelve days after Sgt. La David Johnson’s death, Mr. Trump called his widow.

The conversation did not go well.

The call came about 3:30 p.m. as a limousine with Sergeant Johnson’s widow and her two children sat at Miami International Airport, waiting for the plane carrying her husband’s body.

Representative Frederica S. Wilson, Democrat of Florida and a friend of the family, said she was in the car and heard the president’s comment that Sergeant Johnson “knew what he signed up for.”

The president denied saying it, but for many Americans, the exchange and the public fight it set off is the most enduring part of the ambush.

Sergeant Johnson had been planning to buy the couple’s first house when he returned. Shortly before heading off to Niger last year, he learned his wife was pregnant.

Before joining the Army, he worked in the produce section of the Walmart in a suburb of Miami where he grew up. It was a rough neighborhood, and he was raised by aunts and uncles after his mother died. But friends and family remembered his playful positivity and determination.

“Small resume bout me,” he wrote on Facebook in 2012. “I don’t drink nor smoke, never got arrested, gotta job.”

He was best known around Miami as the Wheelie King, because he commuted to work each day on a bicycle with no front tire, listening to headphones and riding a continuous wheelie that would stretch for miles.

From an early age he loved to pull things apart and put them back together. A knack for customizing cars led him to mechanic school, then to the military.

He was a regular churchgoer and liked to cook. His sister, Torneisha Ghent, said he had been counting the days until he could come home and see his family.

When he finally did return home, it was to live television coverage of his grieving widow, Myeshia Johnson, bent over his coffin as she wept.

Fighting to the End

For at least three of the Americans who died in the ambush, their final moments were recorded.

Helmet-camera footage from Sgt. Jeremiah Johnson was apparently seized by the militants after his death. It was later provided to a news agency in Mauritania, the Agence Nouakchott d’Information, or A.N.I. The New York Times, seeking details that would help explain how the attack occurred, bought rights to the video from the news agency last month. (A.N.I. said it did not make any payment to obtain the video.)

Times reporters, working with a digital forensics expert, were able to verify the video’s authenticity and piece together the final stages of the attack. But because the video shows the deaths of the service members and also includes packaged Islamic State propaganda footage, Times editors decided not to publish the video itself.

In the footage, the three Americans — Sgt. Jeremiah Johnson, Sergeant Black and Sergeant Wright — are cut off in the desert scrub, under intense fire.

Sergeant Black goes down first. Sliding out of the black S.U.V. to help him, Sergeant Wright, the former football player, grabs his friend by the flak jacket and hauls him to the wheel well for cover. He then changes places with Sergeant Johnson and aims over the hood.

The gunfire is coming closer now, from a 45-degree angle.

Sergeant Wright and Sergeant Johnson begin sprinting flat out. The militants are almost on top of them.

Sergeant Johnson, wearing the body camera, trails behind. He is hit and goes down. Sergeant Wright stops running, turns and fires at the militants from behind a bush. The force of his weapon bends the wispy branches like a powerful wind.

The militants are moving toward Sergeant Johnson, who is lying exposed on the ground.

For several long excruciating breaths, Sergeant Wright keeps the militants away. But there’s only so much one soldier can do. The militants shoot Sergeant Johnson several more times, and then turn all of their fire on Sergeant Wright.

He holds them off for as long as he can.