“This is more made up Fake News given by disgusting & jealous failures in a disgraceful attempt to influence the 2020 Election!” Mr Trump tweeted.
The allegations were reported in The Atlantic.
A senior defence department official with firsthand knowledge of events and a senior US Marine Corps officer who was told about Mr Trump’s comments confirmed some of the remarks to The Associated Press, including the 2018 cemetery comments.
The White House swiftly mounted a concerted defence of the president, with Mr Trump’s campaign and allies taking to social media and broadcast interviews to denounce the report.
In the article, defence officials said Mr Trump made the comments as he cancelled visiting the cemetery outside Paris during a meeting following his presidential daily briefing on the morning of November 10 2018.
Staffers from the National Security Council and the Secret Service told Mr Trump that rainy weather made helicopter travel to the cemetery risky, but they could drive there.
Mr Trump responded by saying he did not want to visit the cemetery because it was “filled with losers”, the official said, speaking on condition of anonymity because the official was not authorised to discuss it publicly.
The White House blamed the cancelled visit on poor weather at the time.
In another conversation on the trip, The Atlantic said, Mr Trump referred to the 1,800 Marines who died in the First World War battle of Belleau Wood as “suckers” for getting killed.
Mr Trump, who travelled to Pennsylvania on Thursday, told reporters after he returned to Washington that the Atlantic report was “a disgraceful situation” by a “terrible magazine”.
“I would be willing to swear on anything that I never said that about our fallen heroes,” Mr Trump told the reporters, gathered on the tarmac in the dark.
“There is nobody that respects them more.
“No animal — nobody — what animal would say such a thing?”
Mr Trump also reiterated the White House explanation of why he did not visit the cemetery.
“The helicopter could not fly,” he said, because of the rain and fog.
“The Secret Service told me you can’t do it. … They would never have been able to get the police and everybody else in line to have a president go through a very crowded, very congested area.”
“It’s sad the depths that people will go to during a lead-up to a presidential campaign to try to smear somebody,” said White House Chief of Staff Mark Meadows.
Secretary of State Mike Pompeo told Fox & Friends that he was with the president for a good part of the trip to France.
“I never heard him use the words that are described in that article,” Mr Pompeo said.
Former White House press secretary Sarah Sanders tweeted that she was part of the discussion about visiting the cemetery.
“This never happened,” she said.
“I have sat in the room when our president called family members after their sons were killed in action and it was heart-wrenching. … I am disgusted by this false attack.”
Democratic presidential nominee Joe Biden said that “if the revelations in today’s Atlantic article are true, then they are yet another marker of how deeply President Trump and I disagree about the role of the president of the United States”.
Here’s my promise to you: If I have the honor of serving as the next commander in chief, I will ensure that our American heroes know that I will have their back and honor their sacrifice. Always. https://t.co/wMFHHscD51
— Joe Biden (@JoeBiden) September 4, 2020
“Duty, honour, country — those are the values that drive our service members,” Mr Biden said in a statement, adding that if he is elected president, “I will ensure that our American heroes know that I will have their back and honour their sacrifice — always.”
Mr Biden’s son Beau served in Iraq in 2008-09.
The defence officials also confirmed reporting in The Atlantic that Mr Trump on Memorial Day 2017 had gone with his chief of staff, John Kelly, to visit the Arlington Cemetery gravesite of Mr Kelly’s son, Robert, who was killed in 2010 in Afghanistan, and said to Mr Kelly: “I don’t get it.
“What was in it for them?”
The senior Marine Corps officer and The Atlantic, citing sources with firsthand knowledge, also reported that Mr Trump said he did not want to support the August 2018 funeral of Republican Senator John McCain, a decorated Navy veteran who spent years as a Vietnam prisoner of war, because he was a “loser”.
The Atlantic also reported that Mr Trump was angered that flags were flown at half-staff for Mr McCain, saying: “What the f*** are we doing that for?
“Guy was a f****** loser.”
Mr Trump acknowledged he was “never a fan” of Mr McCain and disagreed with him, but said he still respected him and approved everything to do with his “first-class triple-A funeral” without hesitation because “I felt he deserved it”.
In 2015, shortly after launching his presidential candidacy, Mr Trump publicly blasted Mr McCain, saying: “He’s not a war hero.”
He added: “I like people who weren’t captured.”
Mr Trump only amplified his criticism of Mr McCain as the Arizona politician grew critical of his acerbic style of politics, culminating in a late-night “no” vote scuttling Mr Trump’s plans to repeal the Affordable Care Act.
That vote shattered what few partisan loyalties bound the two men, and Mr Trump has continued to attack Mr McCain for that vote, even posthumously.
The magazine said Mr Trump also referred to former president George H.W. Bush as a “loser” because he was shot down by the Japanese as a Navy pilot in the Second World War.