“I inherited this situation,” Mr. Moreno said in a video address this week.
Fernando Cutz, a former senior adviser to H.R. McMaster, the former national security adviser, and a Latin America policy specialist at the White House, acknowledged that American officials regularly spoke with their Ecuadorean counterparts about handing over Mr. Assange.
But Mr. Cutz argued that Ecuadorean officials did not simply cave to American demands. They wanted Mr. Assange gone as well, he said.
“We would definitely raise it with Ecuador,” Mr. Cutz said. “It was a bilateral irritant, without a doubt. But I don’t think the U.S. pressure ended up being the reason for this move. Bettering relations with the U.S. was just the icing on the cake for Moreno. Assange was his own worst enemy.”
Mr. Assange’s odyssey with Ecuador began in 2012, when he skipped a bail hearing to avoid being extradited to Sweden, where he was wanted for questioning in connection to accusations of “rape, sexual molestation and unlawful coercion.”
Ecuador’s president at the time, Rafael Correa, had been criticized in his own country for a crackdown against the press. But in Mr. Assange, the Ecuadorean president found a symbol of his challenge to the United States, which he called an imperialist power. Mr. Assange was free to stay in the embassy as long as he pleased, Mr. Correa said.
But by 2016, a change in power was afoot in both the United States and in Ecuador. Hillary Clinton, who had run the State Department during the enormous leak of information by WikiLeaks in 2010, was running for president. Mr. Assange also had reason to worry about the coming election in Ecuador, where his stay in the embassy was becoming a campaign issue as well.
On Oct. 7, 2016, a tape was leaked showing Mrs. Clinton’s opponent, Donald J. Trump, boasting of sexually harassing women while filming a segment for the show “Access Hollywood,” sending Mr. Trump’s campaign into a major crisis.