WASHINGTON — Just five days after taking office, over dinner with his newly installed secretary of defense and the chairman of the Joint Chiefs of Staff, President Trump was presented with the first of what will be many life-or-death decisions: whether to approve a commando raid that risked the lives of American Special Operations forces and foreign civilians alike.

President Barack Obama’s national security aides had reviewed the plans for a risky attack on a small, heavily guarded brick home of a senior Qaeda collaborator in a mountainous village in a remote part of central Yemen. But Mr. Obama did not act because the Pentagon wanted to launch the attack on a moonless night and the next one would come after his term had ended.

With two of his closest advisers, Jared Kushner and Stephen K. Bannon, joining the dinner at the White House along with Defense Secretary Jim Mattis and Gen. Joseph F. Dunford Jr., Mr. Trump approved sending in the Navy’s SEAL Team 6, hoping the raid early last Sunday would scoop up cellphones and laptop computers that could yield valuable clues about one of the world’s most dangerous terrorist groups. Vice President Mike Pence and Michael T. Flynn, the national security adviser, also attended the dinner.

As it turned out, almost everything that could go wrong did. And on Wednesday, Mr. Trump flew to Dover Air Force Base in Delaware to be present as the body of the American commando killed in the raid was returned home, the first military death on the new commander in chief’s watch.