HO CHI MINH CITY, Vietnam — As President-elect Donald J. Trump prepared for his inauguration on Jan. 20, 2017, Ted Osius assumed he was about to lose his dream job as the American ambassador to Vietnam.
“I thought I would be put out with the trash on Jan. 21,” said Mr. Osius, 57, a career diplomat for nearly three decades who had once worked for former Vice President Al Gore.
He wasn’t, but he soon fell out with the Trump administration over its effort to deport thousands of refugees from the former South Vietnam who had fled to the United States after the Vietnam War. Last fall, he was abruptly ordered to leave Vietnam, a few days before President Trump arrived to give a speech at the Asia-Pacific Economic Cooperation forum.
Mr. Osius later resigned from the State Department and moved to Ho Chi Minh City, Vietnam’s commercial capital, as a private citizen. He is one of many senior career diplomats who have worked for presidents of both parties, but whose objections to the Trump administration’s policies have led them to leave.
In telephone interviews, officials at the White House and the Department of Homeland Security defended the president’s immigration policies on Vietnam. They said that nearly all the planned deportations that Mr. Osius opposed were for Vietnamese refugees who had been convicted of committing crimes in the United States, and that the Trump administration was merely pressing Vietnam and other “recalcitrant” countries to cooperate with existing United States immigration laws.
“If the former ambassador would like the laws changed, we welcome him to go to Congress and ask them to change the laws,” said Katie Waldman, a spokeswoman for the Department of Homeland Security.
But Mr. Osius said he sees himself not as a rebel, but as a bridge builder.
He was born in Maryland, the son of a physician and a high school English teacher, and attended high school in Vermont. He said his early interest in foreign cultures was forged during a gap year in the Middle East he took after graduation.
“The part that stuck was a fascination with cultures that are very different from ours,” he said on a recent morning in his Ho Chi Minh City living room, surrounded by furniture collected during postings in Vietnam, India and elsewhere in Asia.
Mr. Osius joined the State Department after graduating from Harvard in 1984, and served the first of his 10 postings in the Philippines. He said he quickly discovered that his natural diplomatic instinct — building trust on the basis of shared interests — was sometimes at odds with official American policy.
For example, he said, he blamed a dismissive approach to negotiations with President Corazon Aquino of the Philippines for America’s loss of access to important naval and air bases there in the early 1990s. “She was a woman and she was brown,” Mr. Osius said of Ms. Aquino. “And we were smart and arrogant and didn’t listen.”
Years later, Mr. Osius was part of a group of diplomats who quietly pleaded with the George W. Bush administration to engage North Korea through the so-called six-party talks. As the administration’s North Korea policy hardened, he said, two of his colleagues resigned in frustration.
“This is the dilemma that every professional diplomat faces: What ethical lines won’t you cross?” he said. But in that case, “I decided not to quit but to ride it out and see if I could continue to do some good.”
Mr. Osius has spent decades building diplomatic relationships in Vietnam, a one-party state, where he first served as a political officer in the late 1990s. One of his early tasks there was helping to open the United States Consulate in Ho Chi Minh City, formerly called Saigon.
The idea that he would become an ambassador in Vietnam — or anywhere else — was once inconceivable to him, Mr. Osius said, largely because the State Department’s conservative culture made such senior postings effectively off-limits to openly gay American diplomats like himself.
But by 2014, when then-Secretary of State John Kerry recommended him to President Obama as the next ambassador to Vietnam, the agency’s politics had changed.
“For him in particular, coming here was just a joy,” said Clayton Bond, Mr. Osius’ spouse and a fellow diplomat who also resigned from the State Department last year. “It felt like he had won the lottery.”
Initially, Mr. Osius said, his priority as ambassador was lobbying Vietnamese officials to agree to labor and environmental standards linked to the Trans-Pacific Partnership trade negotiations. (President Trump would later withdraw the United States from the agreement, a move that Mr. Osius described as a “self-inflicted wound” to American interests.)
He also lobbied the Obama administration to host the first-ever White House visit by a chief of Vietnam’s ruling Communist Party, in 2015 — an effort to win over holdouts on the party’s elite Politburo who still held a deeply antagonistic view of the United States.
“In retrospect, that turned out to be the most consequential thing I did,” he said. Vietnam and the United States increasingly see cooperation on security and trade as a hedge against China’s growing regional influence.
Mr. Osius’ fluency in Vietnamese and his frequent public appearances, sometimes with Mr. Bond and their two children in tow, gave him an unusually high profile among the Vietnamese.
The couple also served as a model for gay Vietnamese whose families fear that their sexual orientation will prevent them from having children or successful careers, said Luong Minh Ngoc, the director of iSEE, a Vietnamese research outfit that advocates human rights.
“Ted and Clayton have broken all these stigmas,” she said.
But things changed after Mr. Trump’s election in 2016. Among other things, the couple wondered whether to stop displaying a “gender neutral” bathroom sign — or even photographs of themselves and their children.
“Am I a liability now because I’m black?” Mr. Bond, whose cousin was the civil rights leader Julian Bond, said he thought at the time.
Mr. Osius said that despite his deep objections to the president’s proposed travel ban on people from several Muslim-majority countries, among other policies, he decided to work for the administration anyway — partly out of loyalty to his embassy staff, he said, but also because he wanted to prevent damage to United States-Vietnamese relations.
But that grew more difficult, he said, when he was asked to press the Vietnamese government to accept the planned deportation of more than 8,000 Vietnamese from the United States, most of whom had fled the former South Vietnam as refugees after the war ended in 1975. He said he feared many of them would become human-rights cases, and that the move would anger Hanoi and undercut Washington’s interests on trade and security in Asia.
In a statement, a senior State Department official expressed “disappointment” over Mr. Osius’ remarks. “The State Department is seeking to ensure that all of our foreign partners abide by their international obligation to accept the return of their nationals who have violated our laws,” the official said.
Mr. Osius is now the vice president of Fulbright University Vietnam, a new university in Ho Chi Minh City. He said he planned to leave the position in December, partly to write a book.
He said he had ended a nearly 29-year diplomatic career because he could not bear the idea of again being President Trump’s personal representative. “I couldn’t imagine that being consistent with who I am and what I value,” he said.
Julie Hirschfeld Davis contributed reporting from Washington.