WASHINGTON — Julian Assange’s dramatic arrest this week by United Kingdom authorities at the Ecuadorian Embassy in London and the unsealing of an indictment in federal court in Virginia ended years of speculation about whether the WikiLeaks founder would face criminal charges in the United States.

But Thursday’s flurry of activity was just the first step in what could be a yearslong legal battle to bring him to the US.

The UK is pursuing Assange’s extradition on behalf of the US government, but extradition cases between the two countries are complex affairs. Assuming the defendant doesn’t agree to surrender and contests the removal, there are not only multiple levels for appeals, but multiple forums, too. Defendants have spent years in custody as they fought extradition — one terrorism suspect, Babar Ahmad, who eventually pleaded guilty, was arrested in the UK in 2004 and held for eight years before he was extradited to the US in 2012.

There’s a good chance that however long it takes, Assange will remain behind bars. He was arrested this week not only on the US indictment, but also on a charge in the UK that he violated bail in 2012 to avoid extradition to Sweden, where he faced sexual assault allegations. Amy Jeffress, a lawyer who previously oversaw cooperation between US and UK authorities for the Justice Department, said Assange’s past bail violation would undermine any argument he made for release now.

“He’s already shown he's noncompliant with conditions and I think it’s unlikely a judge would release him given that history,” Jeffress said.

A federal grand jury in Virginia indicted Assange in March 2018 on one count of conspiring to commit computer intrusion by allegedly working with former Army intelligence analyst Chelsea Manning to leak classified military documents in 2010; prosecutors say Assange agreed to try to break a password that would enable Manning to access US Department of Defense computers to obtain documents she couldn’t otherwise get. Assange faces a maximum sentence of five years in prison.

Assange’s lawyer Jennifer Robinson told reporters on Wednesday that Assange planned to fight extradition, saying it would set a “dangerous precedent” for journalists “having published truthful information about the United States.”

Assange is scheduled to have his first hearing on the extradition issue before a judge on May 2. The Justice Department won’t participate in the UK legal proceedings, but will coordinate with their UK counterparts as the case proceeds.

Extradition between the US and the UK is governed by a treaty signed in 2003. In order to extradite someone, the US government has to provide not only the charging documents, but also information that would show a “reasonable basis to believe” that the person committed the crime at issue.

The Justice Department hasn’t submitted its final package of extradition materials to UK authorities yet, though. Instead, they asked for a “provisional arrest,” which requires less information at the start about the underlying evidence. The Justice Department has 60 days to make the formal extradition request. Until they do, they can bring more charges against Assange; but once the package is in, they can’t add any more.

If the Justice Department brought a charge that had the potential for the death penalty, that would complicate the extradition proceedings — the 2003 extradition treaty states that the UK can refuse extradition for a crime that doesn’t carry the death penalty in the UK unless the US promises that capital punishment is off the table. Ecuadorian President Lenín Moreno also announced this week that the UK had confirmed it would not send Assange to a country where he faced the death penalty.

Assange made his first court appearance this week before the Westminster Magistrates' Court in central London; criminal cases begin in the magistrates’ court. A judge found him guilty of breaching his bail conditions when he failed to surrender in 2012 and took refuge in the Ecuadorian Embassy in London to avoid extradition to Sweden.

Assange’s bail breach case will move next to the Crown Court, which handles more serious criminal offenses, where he’ll be sentenced on the bail breach issue. But the extradition case will stay in the Magistrates Court — the two cases can proceed at the same time.

In many cases, the home secretary in the UK, and not a judge, is the final decision-maker on extradition. At each level, judges decide whether to send the case to the secretary to approve or deny an extradition request. If the judge handling his case now rules in favor of sending his case to the secretary, Assange can still appeal to the High Court, the equivalent of an intermediate appeals court in the US.

If the secretary decides to approve extradition, Assange could then try to appeal to the High Court. A ruling by the High Court can be appealed up to the UK Supreme Court, the equivalent of the US Supreme Court.

Assange can raise a host of defenses against extradition, including arguing that he should be protected as a journalist and that the prosecution is politically motivated. Given the prominent role of the home secretary in the process, Assange could pursue a public relations campaign to place pressure on Home Secretary Sajid Javid. In 2012, then–home secretary Theresa May — the current prime minister — blocked the extradition of Gary McKinnon, who was wanted in the US on computer hacking allegations. May said at the time that McKinnon was “seriously ill” and that extradition would violate his human rights.

Javid released a statement Thursday saying he was “pleased” that Assange’s case would go before a court, but he declined to comment on the details of the allegations against Assange.

Even if Assange loses at every level of the UK court system, he still has options. He could petition the European Court of Human Rights to intervene. That court, established in 1959, considers cases claiming violations of the European Convention on Human Rights. The UK is a member of the court, which is separate from the European Union, so even if the UK goes ahead with its exit from the EU, Assange could still appeal to that court.

There’s also a question of what happens if Swedish authorities reopen a sexual assault case against Assange. That case was dismissed in 2017 after prosecutors decided there was no way for them to pursue it while Assange was protected in the Ecuadorian Embassy, but left open the possibility of resuming the investigation if Assange became “available” to the Swedish courts. A lawyer for the woman who said Assange sexually assaulted her released a statement on Thursday calling for the case to be revived.

If Sweden were to reopen the case and file an extradition request, a UK judge would have to decide if the Swedish request gets priority because of its earlier request, or if Sweden now has to get in line behind the US.