HANOI, Vietnam — Visiting Vietnam for the first time, President Trump arrived for an economic summit meeting on Friday in a country still grappling with the legacy of its war with the United States two generations ago — land mines and Agent Orange, and some three million people killed.

Yet here in Vietnam, bitter memories of the war have dissipated — even if its poisonous inheritance has not.

“Both Vietnam and America lost so many men and shared such terrible pain,” said Do Tuan, who won a medal for his bravery in fighting American soldiers during the war and is now a businessman in Hanoi. “The America of the past and the America of the present are different.”

Mr. Trump, in fact, is more popular in Vietnam than he is back at home, according to a Pew survey that found that 58 percent of Vietnamese were confident in his ability to guide international affairs.

The legacy of the Vietnam War — or the American War, as it is known here — is particularly resonant in Danang, the first stop on Mr. Trump’s two-day tour of Vietnam. The central Vietnamese city is hosting the annual Asia-Pacific Economic Cooperation summit meeting, where Mr. Trump is expected to give a speech on the American vision for growth in the Asia-Pacific region.

In 1965, the Ninth Marine Expeditionary Brigade, the first conventional American combat unit deployed in Vietnam, landed on a beach in Danang. Hundreds of thousands more troops would follow over the next few years alone.

Danang’s prettiest stretch of sand, known then as China Beach, gave American troops a sun and surf respite from the war, even as the Communist forces closed in.

Today Danang’s beaches once again lure visitors, and a building frenzy of resorts has brought five-star luxury to one of the world’s five remaining Communist nations. Danang’s city planners fought hard to win rights to host the APEC forum, which will see the leaders of 21 economies in attendance, including President Vladimir V. Putin of Russia and President Xi Jinping of China.

Signs of the warming relationship between the United States and Vietnam are in evidence down the coast from Danang, where an American aircraft carrier is scheduled to make a port call next year, most likely at Cam Ranh Bay, the naval base once used by the Americans.

“When we fight, we must use everything we have, the ancient jungle and the deep ocean, the rivers and the mountains and our bones and flesh,” said Dao Kim Long, a veteran of the American War who also fought the French as a 14-year-old guerrilla. “But when we shake hands, we can begin a friendship with all our heart.”

Vietnam’s tilt toward the United States owes much to the looming shadow of a far more enduring and challenging antagonist: China. Like many countries in the region, Vietnam is keen for an American counterweight to balance against the growing heft of China.

In May, the Vietnamese were given a United States Coast Guard cutter and six new patrol boats to defend the swath of the South China Sea that Hanoi considers its own. Beijing, which has more aggressively asserted that nearly the entire waterway is its own, has clashed repeatedly with Vietnam over competing claims.

In May, Nguyen Xuan Phuc, the prime minister of Vietnam, became the first leader from Southeast Asia to meet with Mr. Trump in Washington. And Mr. Trump will continue an unbroken string of visits to Vietnam by American presidents since diplomatic ties were normalized in 1995.

There are still notable policy differences. The United States ranks as the top destination for Vietnamese exports, and Hanoi was particularly disappointed when Mr. Trump pulled out of the Trans-Pacific Partnership trade pact, which would have given Vietnam better access to its No. 1 market.

Trade is expected to be a major topic during the meetings Mr. Trump will hold with Tran Dai Quang, his Vietnamese counterpart, on Saturday in Hanoi.

“Vietnamese officials are waiting to see if, during Trump’s bilateral meetings, he stays focused on America First or if he raises more substantive suggestions about how the two countries can engage economically,” said Murray Hiebert, a senior associate of the Southeast Asia Program at the Center for Strategic and International Studies in Washington.

During his May meeting with Mr. Phuc, Mr. Trump refrained from censuring Vietnam for its mounting crackdown on dissent, which has resulted in the arrests of dozens of bloggers, religious leaders and activists.

In a Nov. 7 letter, 20 members of the House of Representatives, from both parties, called for Mr. Trump to raise “Vietnam’s dismal human rights record” when he sees Mr. Quang on Saturday.

Five decades ago, Mr. Trump was exempted from military service during the Vietnam War with a bone spur diagnosis. On Friday, in between events at the Asia Pacific Economic Cooperation summit, Mr. Trump met with American veterans of the Vietnam war and signed a proclamation commemorating the conflict’s 50th anniversary.

“Each of you, under the most difficult conditions, did what you had to do, and you did it well,” Mr. Trump told the veterans. “They’re brave, they’re strong, they’re great patriots, and we just want to thank you and all of the thousands and thousands, and all of the people that served with you and in all of the other wars.”

He said his administration was working to secure the return of 1,253 veterans still missing in Vietnam and that it “will not rest” until they are brought home.

The president’s first contact with Vietnam was on land contaminated by the United States military half a century ago.

Danang’s airport is on the site of an old American air base where barrels of the defoliant Agent Orange were once stored and mixed. Dioxin, a toxic contaminant, seeped into the ground and nearby water sources.

Since then, families living in the area have experienced higher rates of children with birth defects, most of which render them severely disabled. Nationwide, the Vietnamese Red Cross estimates that three million Vietnamese have been damaged by dioxin poisoning, either from their parents’ exposure or from the polluted environments themselves.

After decades of rejecting any link between dioxin and a multitude of cancers, birth defects and other physical ailments, the United States government in 2007 started to address the health and environmental consequences of the toxic compound in Vietnam.

Five years later, the Americans began paying for the decontamination of the area around the Danang airport, where dioxin readings 365 times the safe level were found. By the middle of next year, the area should be entirely free of dioxin residue. (Efforts to fund further dioxin cleanups have caused budgetary wrangling between the State Department and the Pentagon.)

“Only a few years ago a large portion of the Danang airport was a toxic waste site that posed grave risks to human health,” said Senator Patrick Leahy, the Vermont Democrat who has led the congressional effort to redress one of the world’s most persistent chemical assaults on the environment.

“Today it is a fully functioning airport for a city of 1.3 million people,” said Mr. Leahy, who visited Danang in 2014. “The fact that this very location is the site of the APEC summit, attended by the president of the United States, speaks volumes.”