SAN PEDRO SULA, Honduras — A week after another U.S. federal court filing implicated him in drug trafficking, the president of Honduras was in a helicopter zipping over a remote mountain range, scrolling through Twitter.

It was mid-January, and Juan Orlando Hernández was trying to calculate what Washington’s political transition meant for his country — and for him. He flicked past news of Donald Trump’s impeachment, past a Nikki Haley tweet about “liberal elites,” past a preview of Joe Biden’s inauguration.

For four years, Hernández had built his governing program around the demands of the Trump administration, which in turn had stayed out of Honduras’s domestic affairs. Now that arrangement was ending. Hernández, like other leaders around the world, was preparing for an extreme change in American foreign policy — and trying to figure out how to refashion himself from a Trump ally into a Biden one.

The stakes are higher for Hernández than perhaps any other world leader. Not only are the political and economic fortunes of his country inextricably linked to the United States but Hernández is one of the few sitting presidents ever to be implicated in drug trafficking by the U.S. Justice Department.

He has not been charged, but prosecutors have described evidence against him in multiple indictments, including one against his brother, Tony, a former congressman in Honduras who was convicted in federal court in Manhattan in 2019 of cocaine trafficking. In that case, the Justice Department said Tony Hernández had delivered a $1 million bribe from Sinaloa cartel leader Joaquín “El Chapo” Guzmán to Juan Orlando Hernández in 2013. The president denies that allegation and any other alleged ties to drug trafficking.

If he were charged, he could face extradition when his term ends next year — or, if the U.S.-Honduras relationship sours, sooner. But Hernández, who describes Biden as an old colleague, is hopeful.

“We will have to sit down, talk and see the progress that has been made” in Honduras, he told The Washington Post. “I always felt that Biden was more pragmatic” than Trump, “and always very courteous.”

In November, Hernández tweeted a photo of himself with Biden in 2015, Biden’s hand clutching Hernández’s upper arm. “I hope we can work together,” he wrote, “like in the past.”

Hernández and his aides have tried to charm Democratic lawmakers, fired their lobbying firm, welcomed a new U.N. office focusing on drugs and crime, and revived talking points on climate change. The controversial migration pact Hernández signed with Trump? Now he described Trump’s approach as “aggressive.” Hernández, by his own account, was ready to move on.

But in the middle of that effort, the Justice Department released a new indictment. In the U.S. case against alleged drug trafficker Geovanny Fuentes Ramírez, prosecutors quoted Hernández as saying he “wanted to shove the drugs right up the noses of the gringos” by using Fuentes’s cocaine laboratory to increase production.

“Ridiculous,” Hernández said. (Fuentes, arrested in Florida in March, has pleaded not guilty.)

It is now another issue to resolve with the new administration, one less likely to look the other way. Hondurans will be watching closely. Given the fragility of the country’s judicial system, Hernández’s many critics believe their only shot at justice is in the United States. “Fuera la narcodictadura” — “Get the narcodictatorship out” — has become a rallying cry.

“Hernández thinks he can get out of the Department of Justice noose,” said one senior U.S. official. “So he’s signaling every willingness to work with the new administration.”

Hernández, flying over the country’s verdant countryside in the presidential helicopter, rattled off the connections between the two countries evident in the landscape below.

He pointed out a U.S. military base, the only one in Central America. A new Nike factory. Puerto Cortés, from which tankers loaded with Honduran products sail for the United States. In the distance lay San Pedro Sula, where at that moment a caravan of thousands of Honduran migrants was hours away from leaving for the U.S. border. 

There is another connection: Every year, thousands of pounds of cocaine transit through Honduras on the way to the United States. According to the Justice Department, some of that cargo is trafficked by Honduran officials — an allegation the Trump administration mostly ignored while officials praised Hernández’s counternarcotics and anti-migration efforts.

“It was all about migration for Trump. It was purely transactional, and Hernández knew how to give Trump what he wanted,” said the senior U.S. official, who was not authorized to speak publicly on the subject and commented on the condition of anonymity. “When we tried to push other issues, like anti-corruption issues, we didn’t get any traction at the highest levels.”

Honduran officials quickly recognized that the Trump administration was not interested in pressing Hernández on the accusations.

“In my 30 meetings with various actors in Washington, the allegations against him never came up,” Foreign Minister Lisandro Rosales said.

The Trump State Department said in a statement in January that the United States uses its “diplomatic engagement with the Government of Honduras to support the rule of law and the fight against corruption and impunity.”

“We take any allegations of criminal activity very seriously,” the statement said. “Department officials engage with a wide variety of Honduran government officials, in all branches of government, political parties, civil society actors, and the private sector to achieve our objectives.”

Trump’s focus was on blocking Hondurans from getting to the U.S.-Mexico border, or from applying for asylum once they arrived. But analysts say it is poor governance in Honduras — one of the most violent nations in Latin America, and one of the most corrupt in the world, according to Transparency International — that prompts migration to the United States.

Biden has outlined those issues in his Central America policy plan, a document read by Hernández’s team with interest and concern. Elements include “revoking visas to the United States and freezing assets of corrupt individuals from El Salvador, Guatemala, and Honduras.”

In all three countries, Biden will inherit relationships transformed by the Trump administration. Trump praised El Salvador and Guatemala for their policies to slow migration but took no action when Guatemala dissolved its U.N.-backed anti-corruption agency or when critics accused El Salvador’s president of encouraging excessive force to fight gang violence.

Whatever Biden does to restore accountability to U.S. foreign policy, it is likely to be Hernández who has the most to lose. For more than a decade, he has navigated changes in U.S. policy, shape-shifting as necessary to insulate himself. But it is the extradition treaty with the United States that he pushed to implement when he was president of the Honduran Congress that now might pose the biggest threat to him.

“President Hernández, like many foreign leaders, has been very skillful at telling people in Washington what they want to hear,” said Sen. Patrick J. Leahy (D-Vt.). “But the reality is that democracy and human rights are under assault in Honduras, and corruption permeates the government.”

Hernández has studied U.S. politics since his stint in a master’s program at the State University of New York at Albany. He grew up on a small coffee farm in the city of Gracias, near the Salvadoran border, one of 17 children. As he came of age politically, he came to believe that winning over the United States was a necessary survival skill.

In 2003, while a member of Congress, he lent his office to State Department officials, who used it to rally Honduran lawmakers to support the Iraq War. U.S. diplomats presented him with a pair of George W. Bush cuff links, U.S. officials said. When Barack Obama was president, Hernández championed a program aimed at stemming migration by increasing security and employment.

With Trump in office, Hernández’s administration agreed to block Central American migrants from seeking asylum in the United States. After the Trump administration moved the U.S. Embassy in Israel from Tel Aviv to Jerusalem, Hernández announced that Honduras would move its embassy there as well.

“Hernández has always known which U.S. priorities to support to maintain the relationship,” said Adriana Beltrán of the Washington Office on Latin America.

Meanwhile, the allegations have piled up. They include the claim by U.S. prosecutors that the Mexican drug lord Guzmán had given Tony Hernández $1 million for his brother’s presidential campaign. Tony Hernández’s attorneys argued during his U.S. federal trial that there was no evidence to prove the claim. Prosecutors also claim Juan Orlando Hernández had agreed “to facilitate the use of Honduran armed forces personnel as security” for drug traffickers.

Hernández said he called his brother personally and told him, “If you did something wrong and they detain you, it’s your responsibility.” He told his mother he supported his brother’s extradition. She was furious, he said.

“I have two roles,” he said, “the role of a brother and the role as head of state.”

Hernández calls the accusations against him absurd, arguing that they come from alleged criminals who are trying to reduce their prison sentences.

“It is a very strange situation,” he said. “In other justice systems around the world, this would not be considered a valid testimony.”

Trump backed Hernández when he won reelection, despite fraud allegations, in 2017. The United States did not stop Honduras from quashing an anti-corruption agency last year. Officials continued to work with Hernández, formalizing an agreement last year that allows the United States to send non-Honduran asylum seekers to Honduras to file their claims there.

“President Hernández is working with the United States very closely,” Trump said in December 2019. “You know what’s going on on our southern border. And we’re winning after years and years of losing.”

Hernández’s administration seized upon the recognition.

“These are really the words of a friend,” Rosales, the foreign minister, said at the time.

Two days before Tony Hernández was convicted, the U.S. Embassy in Honduras tweeted that “our governments cooperate on a wide range of issues including migration, security, the fight against narcotics, and economic development.”

U.S. diplomats and Honduran activists recoiled.

“We watched the Honduran government grow more corrupt, more abusive, and the only check on those problems — the United States — had vanished,” said Gabriela Castellanos, the head of the National Anti-Corruption Council, which for years has received support from the U.S. Agency for International Development.

The Trump State Department defended its role.

“Embassy officials meet regularly with the Honduran government to address specific human rights cases, advocate for improving human rights and anti-corruption efforts, and work to improve prosperity and security in Honduras,” it said in January.

But since Biden’s election, those in Hernández’s inner circle have grown concerned. They worry that Democratic critics such as Leahy and Rep. Norma J. Torres (Calif.) will have a stronger role in crafting policy.

After the election, State Department officials created an internal policy of avoiding photos with Hernández, according to a U.S. official. House Speaker Nancy Pelosi (D-Calif.) and a group of Democratic members of Congress refused to meet with him when they visited Honduras in 2019.

“I don’t think he fully understands the change that is about to come,” said Torres, who was on that trip. “My hope is that we will find a way to undo the great damage his government has done while the Trump administration looked away.”

Senior Honduran officials sent four requests to meet with Torres as they tried to endear themselves to a Democratic administration. She did not respond.

“From Representative Torres’s perspective, there is no point for a lawmaker to sit down with the representative of any foreign government, and particularly a narco state, ahead of the new administration,” said her spokesman, Dan Lindner.

It is rare for the United States to indict a head of state. But Hernández’s term ends next January. Analysts worry he will try to cling to power — he says he won’t — or undo the country’s extradition treaty before he steps down. Honduran officials say Hernández has no plans to change the extradition law, a process that would require approval by two consecutive legislatures.

For now, at least publicly, it appears his strategy is the same as it has always been: win over a new U.S. president.

At the edge of Honduras’s desolate Mosquito Coast, Luis Suazo, the country’s ambassador to the United States, stood next to the wreckage of an airplane that had crash-landed, weighed down by thousands of pounds of cocaine. On one wing, someone had emblazoned a fake U.N. insignia, in an apparent attempt to fool the Honduran military.

Suazo, a former security minister, has been tasked with winning over the Biden administration. Now he was highlighting the country’s progress against gangs and drug traffickers.

In 2011, Honduras was the largest cocaine transshipment country in the world, according to the State Department. By 2019, the department reported, only 4 percent of shipments that reached the United States made a first stop here.

“I want to congratulate the Government of Honduras for its excellent work,” Adm. Craig S. Faller, the head of the U.S. Southern Command, said when he visited Hernández in December.

It was praise that Hernández and his staff circulated widely: Why would a president involved in drug trafficking crack down on drug trafficking?

“It doesn’t make any sense,” Suazo said. “We’ve been willing partners in the fight against drug trafficking, and the numbers bear that out.”

Behind him, a unit of Honduran soldiers buried dynamite near the decomposing plane. They were here to destroy the clandestine runway on which its pilot had tried to land — and had invited a Washington Post correspondent to watch. It was yet another part of Hernández’s new messaging campaign.

Soldiers destroyed a makeshift runway in Gracias a Dios, Honduras, on Jan. 13, a day after a plane with thousands of pounds of cocaine crash-landed there. (Kevin Sieff/The Washington Post)

After Hernández was elected in 2013, he sponsored a “purification” of the country’s police, an effort backed and funded by the United States, which led to the dismissal of half the force. He helped legalize extradition from Honduras to the United States.

Current and former U.S. officials said that there were rumors Hernández was complicit in drug trafficking during the early years of his presidency but that there never was any explicit intelligence implicating him. The officials say they have been able to back counternarcotics efforts in a country known for institutional corruption by partnering with military and police units whose members have passed polygraph tests.

“The DEA works hand in hand with these vetted units through shared intel and bilateral investigations to support Honduran operations,” the Drug Enforcement Administration said in a statement.

Biden has proposed spending $4 billion in Central America to improve security and develop the economy. It is unclear what role Hernández would have. When Biden led development efforts in Central America in 2015 aimed at deterring migration, Hernández toured Washington think tanks to promote the strategy, called the “Alliance for Prosperity.” It seems unlikely he will play a similar role this time. But he has begun to try.

“It’s vintage Juan Orlando,” said a former U.S. official, speaking on the condition of anonymity to discuss ongoing diplomatic affairs. “He’s asking himself, ‘What can I do today to show the Biden people that I’m a strong partner?’ ”