Trump went to Dover AFB on Marine One, along with his daughter, Ivanka, and Sen. Chris Coons of Delaware.
Chief Petty Officer William "Ryan" Owens, a Navy SEAL, died of wounds suffered during a raid Sunday in Yemen against al Qaeda, according to US Central Command.
Sources in Yemen told CNN that three senior al Qaeda leaders were among those killed. That was later confirmed by a US official.
Trump, in an unannounced visit, marked the somber occasion by partaking in the dignified transfer ceremony to honor Owens.
Trump later described the ceremony as "very sad, very beautiful," in remarks at a White House swearing-in of Secretary of State Rex Tillerson.
Trump approved the operation, which had been in the planning stages for months under President Barack Obama.
Presidents don't often attend dignified transfer ceremonies. Obama attended several of these ceremonies, including in 2011 after a US-Afghan joint raid resulted in the deaths of 38 US and Afghani troops.
Owens was the only US service member to die in the operation, which killed an estimated 14 al-Qaeda in the Arabian Peninsula members. The raid also resulted in the death of the 8-year-old daughter of former al Qaeda leader Anwar Al-Awlaki, a US citizen who was killed in a drone strike in 2011.
Trump spoke over the weekend with Owens' wife and offered his condolences to Owens' father and three children.
The raid yielded what White House press secretary Sean Spicer described Wednesday as a "an unbelievable amount of intelligence that will prevent the potential deaths or attacks on American soil."
Obama participated in his first dignified transfer in October 2009 to honor the return to US soil of the remains of 15 service members and three Drug Enforcement Administration agents killed in Afghanistan. Obama also flew to Andrews Air Force base in 2012 to receive the remains of four Americans killed in the attack on the US consulate in Benghazi.