The secrets came directly from the phones of President Lenín Moreno of Ecuador: intimate pictures of him and his family on vacation, text messages from his wife, even a photograph of the president himself in a posh bedroom, eating a lobster in bed.
The material, published last month on an anonymous website, was particularly embarrassing because Mr. Moreno was in a bruising national fight over his austerity measures. But rather than mount a defense, the president played the victim: He blamed WikiLeaks, whose founder, Julian Assange, had spent the last seven years holed up in the country’s London embassy.
WikiLeaks’ actions were “despicable,” said the country’s vice president on television, vowing to take action. The group denied leaking the information, but on Thursday Ecuador made good on its threat — opening the door to British police officers who carted away Mr. Assange.
With that, Mr. Assange’s long refuge inside the Ecuadorean Embassy finally came to an end, the capstone of an international cat-and-mouse game involving stolen document dumps, promises of more to come, failed efforts to contain him and accusations of blackmail.
Even as Ecuador harbored Mr. Assange from international prosecution, he and WikiLeaks wielded the threat of releasing damaging information against the Ecuadorean government.
In October 2016, as WikiLeaks was releasing thousands of emails hacked from the Democratic National Committee and the personal account of John D. Podesta, the chairman of the Clinton campaign, Ecuador restricted Mr. Assange’s access to the internet, citing his interference in a foreign election.
The United States may have played a central role in the effort to corral Mr. Assange. On Oct. 14, with the emails upending the campaign and the election just weeks away, a confidante of the Clintons and a top aide to Secretary of State John Kerry showed up at a dinner party hosted by the Ecuadorean ambassador before a ball, lingering with him as other guests left, several attendees said.
Mr. Assange’s internet was curtailed by the Ecuadorean Embassy the very next day.
But WikiLeaks quickly retaliated, issuing a cryptic message that a leak against Ecuador was on its way. The tactic seemed to work. Two months later, Mr. Assange said in an interview that his internet had been restored.
Mr. Assange has been hailed by many around the world as a champion of transparency and a casualty of his own success at revealing secrets.
Diane Abbott, another Labour Party official, made the same assertion, arguing that Mr. Assange “is not being pursued to protect U.S. national security; he’s being pursued because he has exposed wrongdoing by U.S. administrations and their military forces.”
But Ecuadorean officials contend that the expulsion comes from an extensive list of transgressions by Mr. Assange that soured their long — and often strained — relationship.
In explaining his decision, Mr. Moreno accused Mr. Assange of installing electronic distortion equipment in the embassy, blocking security cameras, confronting and mistreating guards and gaining access to security files without permission.
On Thursday, the government said it had also arrested a computer programmer in Ecuador in connection with the Assange case, contending that WikiLeaks had interfered in Ecuador’s domestic political affairs.
WikiLeaks insisted it was not involved in the hack of Mr. Moreno’s phones, and that the Ecuadorean government was using the episode as a false pretext to toss out Mr. Assange.
It was no secret that the United States wanted him removed. It was also clear that Mr. Moreno is eager for international loans and better relations with the United States after the tensions that festered under his leftist predecessor, who granted Mr. Assange shelter in the embassy.
“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.
WikiLeaks continued to release the emails throughout October on a daily basis. American intelligence agents later concluded that the documents had been hacked by Russian operatives and laundered through WikiLeaks.
When Ecuador restricted Mr. Assange’s internet access in response, Mr. Correa’s administration said that it had acted on its own accord, not because of pressure from the United States. A spokesman for Mr. Kerry also denied that the Obama administration played any role.
But during the encounter on Oct. 14 — the night before Mr. Assange’s internet access was restricted — Patsy Thomasson, a veteran of the Clinton White House, and a senior aide to Mr. Kerry attended a dinner at the Ecuadorean Embassy hosted by Francisco Borja, the ambassador of Ecuador.
Attendees interviewed said it struck them as odd that such high-powered players would decide to attend a party hosted by a small country’s ambassador. They noted that neither Ms. Thomasson nor the Kerry aide was dressed in black tie for the ball, and that both stayed behind with the ambassador after other guests left for the event.
Ms. Thomasson, reached by phone, said she had been invited at the very last minute by someone whose wife couldn’t come, and that she did not recall having any conversations with the ambassador, “much less about Julian Assange.”
WikiLeaks struck back soon after. On Oct. 16, the day after Mr. Assange’s internet was restricted, WikiLeaks tweeted a code, known in its parlance as an “insurance file,” and signaled that an upcoming leak involving Ecuador was imminent.
Mr. Assange certainly seemed to have acquired compromising material. In 2015, Cynthia Viteri, a prominent Ecuadorean politician, and Fernando Villavicencio, an Ecuadorean political journalist, had gotten secret documents showing that Ecuador was running a surveillance program, using an Italian company to spy on journalists and political enemies, in addition to spying on Mr. Assange at the embassy.
Mr. Villavicencio said he sent the material to a WikiLeaks email address, hoping the organization would publish the information. He eventually published the documents himself. WikiLeaks never did, though it is clear from leaked 2015 chat group logs from WikiLeaks Forum, a related site, that Mr. Assange and his inner circle were aware of them.
Mr. Villavicencio said he believed the documents he sent to WikiLeaks may have been among those that Mr. Assange had threatened to publish.
“There was very valuable information, information of millions of dollars in expenses, tens of millions of dollars in contracts to foreign companies to do illegal hacking — and it surprised me it didn’t get out,” he said. “It was information of international and national interest.”
Nothing ever came of the Ecuador-related “insurance file” WikiLeaks tweeted about in October 2016.
“From 2011, WikiLeaks did not leak relevant information regarding Correa’s government,” Mr. Villavicencio said. “That certainly shows hypocrisy and a double standard, contradicting journalism principles.”
The controversy was just the beginning of Mr. Assange’s difficulties. Mr. Moreno took over as president in May 2017 and soon broke with the policies of his predecessor.
Then, Mr. Moreno’s government was hit by a familiar disruption: more leaks.
In March, an anonymous website, INApapers.org, published around 200 private emails related to Mr. Moreno, text messages written by his wife and photos of the president and his family taking luxurious vacations in Europe.
Mr. Moreno’s government was quick to blame the release on WikiLeaks, which it says Mr. Assange still controls.
On Thursday, Mr. Moreno repeated the claim, telling Ecuadorean journalists that Mr. Assange didn’t have the right to “hack private accounts or phones.”