Senior and former military leaders appeared to struggle Friday with how to respond to a report that President Trump disparaged U.S. service members killed in combat as “losers,” as the president attacked the allegations as “fake news.”

The article elicited an array of reactions amid Trump’s history with the military, which includes mocking Sen. John McCain (R-Ariz.) for being captured in Vietnam, belittling the parents of an Army officer killed in Iraq, and dismissing brain injuries suffered by U.S. troops in an Iranian ballistic missile strike as “headaches.”

The report in the Atlantic, published late Thursday, focused in part on a presidential visit to Arlington National Cemetery on Memorial Day in 2017 and a canceled visit to the Aisne-Marne American Cemetery outside Paris in 2018.

In the first example, according to the magazine, Trump allegedly said, “I don’t get it. What was in it for them?” while standing with retired Marine Gen. John F. Kelly at the grave of Kelly’s son, Robert, who was killed in Afghanistan. At the time, Kelly was homeland security secretary.

The Fix’s Aaron Blake analyzes what President Trump has allegedly said about fallen troops and how those statements echo previous comments by the president. (The Washington Post)

In the second, the Trump administration canceled the visit to the cemetery in France in bad weather when helicopter travel was questionable and Trump seemingly dismissed the World War I veterans who are buried there.

“Why should I go to that cemetery?” Trump said, according to the report. “It’s filled with losers.”

The president vehemently denied the report, attacking the Atlantic as a “third-rate magazine” and criticizing Kelly for not doing a good job as his former chief of staff.

“This man was totally exhausted. He wasn’t even able to function in the last number of months,” Trump said. He added that he did not know whether Kelly served as a source for the Atlantic’s story, “but it could have been a guy like a John Kelly.”

Defense Secretary Mark T. Esper defended the president’s work with the military, veterans and their families.

“President Trump has the highest respect and admiration for our nation’s military members, veterans and families. That is why he has fought for greater pay and more funding for our armed forces,” Esper said in a statement, which did not ­specifically address the inflammatory comments attributed to Trump.

A senior defense official, speaking on the condition of anonymity because of the ­sensitivity of the issue, said Esper had not heard about the comments attributed to Trump until the Atlantic’s story was published.

Retired Navy Adm. James Stav­ridis, sharing the Atlantic article on Twitter, described the military’s cemeteries as “sacred shrines to those who have given everything” and suggested that the lack of denials by Kelly and retired Marine Gen. Jim Mattis, Trump’s former defense secretary, were notable.

“The phrase: ‘shocking if true’ is getting worn out,” Stavridis tweeted. “Lack of denial from my friends Generals Kelly and Mattis suggest the shock is well placed.”

Stavridis added in an email to The Washington Post that he hopes Kelly and Mattis, “if they do have firsthand knowledge of such quotes, will step up and affirm or deny the story.”

Mattis and Kelly did not respond to requests for comment Friday. Other retired Marine generals who have worked with them, including Gen. Joseph F. Dunford Jr. and Gen. John R. Allen, declined to comment.

Another retired officer, Army Gen. Tony Thomas, criticized former CIA director John O. Brennan for tweeting that an unnamed four-star general who worked for Trump had called the president “the most loathsome individual” he had ever met.

“JOB, my former boss, how is this helpful?” Thomas said on Twitter. “Another unnamed General (did he ask you to speak for him)? Actually hurts our profession to have unattributed allegations like this flying around and only serves to stoke both extremes.”

Another retired Marine said in an interview that Kelly had shared a similar story about Trump’s Memorial Day comments with him after they met by chance at Arlington National Cemetery on a later date. He spoke on the condition of anonymity, citing his current work with the government.

Kelly’s son, 1st Lt. Robert Kelly, was among three service members who were memorialized by Trump in the ceremony on Memorial Day in 2017.

The father of one of the others, Spec. Christopher D. Horton, said Friday that Trump greeted his family warmly at Arlington National Cemetery that day and that the comments attributed to the president in the Atlantic did not match his experience.

“He wanted to know if we wanted some photos, and we said yes,” said the fallen soldier’s father, David. “He said very complimentary things to us like, ‘Your son was a winner. You are all winners,’ which is kind of the way he speaks. I left there feeling very honored and very esteemed.”

Christopher Horton’s widow, Jane, works in the Pentagon on issues pertaining to the families of deceased service members, first during the Obama administration and now as a Trump appointee.

Retired Gen. Robert B. Neller, the former commandant of the Marine Corps, said in an email that he had no knowledge of any of the comments attributed to Trump. But he highlighted the sacrifices U.S. troops made during World War I and said France was the first real U.S. ally and “we should not forget that.”

America has a role and requirement, Neller wrote, to properly recognize the service of its veterans, take care of those who are wounded, and remember those who do not return from combat.

“I believe we as a Nation do that well,” Neller wrote. “In France, on numerous occasions I have had French citizens thank me for the efforts of Americans in both wars to defend and liberate France. I believe our actions as a Nation were a good and proper thing . . . though the cost was high.”

The muted reaction from retired officers comes after Mattis lashed out at Trump in an essay in June, accusing the president of trying to divide Americans and taking exception to his interest in using active-duty military forces against U.S. citizens protesting after the police killing of George Floyd.

“Donald Trump is the first president in my lifetime who does not try to unite the American people — does not even pretend to try,” Mattis wrote. “Instead, he tries to divide us.”

Mattis’s rebuke was described by some critics as too little, too late, in response to the president, and as an affront by others. John Dowd, a Marine veteran who served as Trump’s lawyer, accused Mattis of being used by politicians and not being able to kill the Iranian general Qasem Soleimani, who died in a drone strike approved by Trump in January.

“Perhaps, your anger is borne of embarrassment for your own failure as the leader of Central Command,” Dowd wrote in a message that was posted by Trump on Twitter.

Peter Feaver, a scholar on civil-military relations at Duke University, said that retired senior military leaders were unlikely to speak out now. While Mattis and others took the unusual step of criticizing the president in June, their remarks came after Trump expressed a desire to use the military against civilians and current Pentagon leaders were photographed with him after protesters were cleared with force, he said.

The current situation is different, Feaver said, because even though the reported comments would be seen as offensive, former leaders would probably prioritize abiding by norms keeping them out of political brawls, especially this close to an election.

“There’s not a misuse of the military that’s at stake here,” he said.

The same is even more true for serving military leaders, who are obligated to follow any legal order. Still, Feaver added, the comments could undermine confidence in the commander in chief among service members, who vow to risk their lives in response to orders by national leaders.

“It is good for the civil-military relationship when the military trusts that the president has their back, that he understands the sacrifice they’re making, and is not cavalier about their death,” Feaver said.

The reactions to the report stretched to military nonprofit organizations, which were forced to consider how to respond to reported comments that were offensive without clarity on their accuracy.

The president of the Tragedy Assistance Program for Survivors (TAPS), a nonpartisan nonprofit organization founded to help families of deceased service members, raised the Atlantic story with the group’s board members Friday, according to an internal email obtained by The Post.

Bonnie Carroll, who founded TAPS after her husband was killed in a military plane crash, said in the email that TAPS “is standing strong today with our surviving families, and reminding them that America has steadfastly, historically honored those who have paid the ultimate sacrifice for our freedom.”

Carroll added that TAPS has reaffirmed to families that it is there for them, and that it would comfort them “on this difficult day and rally around them with care.” The organization confirmed the authenticity of the email.

TAPS ultimately published a graphic on Twitter stating that Americans have “steadfastly honored those who have paid the ultimate sacrifice for our freedom,” and that fellow Americans have “draped their caskets with our nation’s flag, and laid them to rest in the hallowed grounds of our national cemeteries.” The group planned to send an email to tens of thousands of members Friday night.

Brian McGough, a former soldier who was severely wounded when an improvised explosive device exploded near his vehicle in Iraq in 2003, said Trump’s alleged remarks were shocking but not surprising, given his previous public comments.

McGough said that he wanted military leaders to speak out in support of troops, but that “you don’t get to be a four-star or a general on the Joint Chiefs by speaking out. They’re playing the long game.”

McGough’s wife, Army veteran Kayla Williams, said she was “appalled” by the report.

Williams, who now volunteers for a veterans group supporting Joe Biden for president, said fellow veterans, including some who continue to serve as reservists, told her they were shocked by the alleged remarks.

She said that for her and those fellow veterans the report appeared to show that Trump “does not have any emotional comprehension of the risks they’re willing to make for our country.”