MADRID — This much has become clear in recent weeks: When Julian Assange, the WikiLeaks founder, was living in Ecuador’s embassy in London, someone was spying on him, recording his private conversations. The question is: Who ordered the surveillance?
Mr. Assange — in jail in Britain and facing prosecution in the United States — is scheduled to testify remotely later this month before a Spanish judge in a criminal case accusing a Spanish security company of eavesdropping on him illegally.
The Spanish court case has revealed a new set of secrets in the international saga of Mr. Assange, 48, showing that his claims of being spied on were not just paranoia or a publicity stunt. But as with all things related to someone who has been labeled a villain and a hero, a prophet and a crank, the revelations are subject to conflicting interpretations.
In Spain’s National Court, a public prosecutor and Mr. Assange’s lawyers have presented a raft of evidence that he was recorded while in the Ecuadorean Embassy, which they say violated his right to privacy. The material includes video recordings, reviewed by The New York Times, in which his conversations with visitors are audible.
The prosecutor and Mr. Assange’s allies argue that the C.I.A. was behind the spying. A spokesman for the agency declined to comment.
After President Trump took office in 2017, the C.I.A. began espionage aimed at Mr. Assange, WikiLeaks and their ties to Russian intelligence, and the Justice Department began building a criminal case against him. But it remains unclear whether it was the Americans who were behind bugging the embassy.
The case adds another layer of complexity to the legal travails of Mr. Assange, who has been indicted in the United States on charges of espionage and hacking that exposed classified national security secrets. The Justice Department has asked Britain to extradite him, and British courts have begun considering the request.
His lawyers plan to introduce evidence from the Spanish case into the extradition case, arguing that it should block the British government from turning him over to the Americans. They say that the surveillance includes recordings of privileged conversations Mr. Assange had with his lawyers and doctors, and proves that he cannot receive a fair trial in the United States.
The British courts are unlikely to accept that argument, according to Amy Jeffress, a lawyer at Arnold & Porter in Washington and a former Justice Department attaché at the American Embassy in London. She said the legal standard is whether extradition would comply with Britain’s Human Rights Act, which protects the right to privacy but balances it against considerations like national security and fighting crime.
Mr. Assange is scheduled to testify on Dec. 20 by videoconference from Westminster Magistrates’ Court before Judge José de la Mata some 800 miles away, in Spain’s National Court in Madrid. The judge is handling the investigation into UC Global, a Spanish firm that was in charge of security at the Ecuadorean Embassy during Mr. Assange’s long stay there.
David Morales, who founded UC Global after many years in the Spanish military, was indicted in October, charged with privacy violation, bribery and money laundering. He denied wrongdoing, and Judge de la Mata released him pending a trial, but ordered him to surrender his passport and report regularly to the authorities.
One of Mr. Morales’s early security jobs was protecting the daughters of Rafael Correa, the president of Ecuador at the time, who were living in Europe. That paved the way for a contract with Ecuador’s embassy in London.
In 2017, Mr. Morales overhauled the security equipment and procedures at the embassy, replacing surveillance cameras with new ones that had microphones, according to a 61-page court filing by the public prosecutor. Mr. Assange was repeatedly assured by Ecuadorean officials that he was not being recorded.
In reality, he was. He took precautions like using a white noise device in an attempt to mask conversations, and the Spanish prosecutor says UC Global took steps to counteract them.
The company put microphones in embassy restrooms, where Mr. Assange sometimes held meetings for greater privacy, the court filing says. And it states that UC Global placed a microphone in a meeting room, hidden in a fire extinguisher, that could record up to 12 hours of sound.
Recordings were sent to the company’s headquarters in Jerez de la Frontera, in southern Spain, the prosecution says — a charge that Mr. Morales denies. When he was detained, the police also raided his home and company, and have since been decrypting emails and information from his confiscated cellphone.
The court case also relies on the testimony of some former employees of UC Global who have been granted witness protection. They said that Mr. Morales traveled to the United States once or twice a month, carrying with him hard disks containing recordings from inside the London embassy.
Mr. Morales repeatedly ordered them not to talk with Ecuadorean officials about his trips, they said.
In the court filing, the prosecution asserts that Mr. Morales returned from a security fair in Las Vegas in 2015, gathered his employees and told them that UC Global was going to work “for the dark side,” which he explained as referring to the United States authorities.
He signed a contract with Las Vegas Sands, the casino and resort company of Sheldon Adelson, and the prosecution contends that Mr. Morales passed information about Mr. Assange to security officials at the company, saying it acted as a go-between with the C.I.A.
In his hearing before the Spanish judge, Mr. Morales said that any secret recording made at the London embassy was done on behalf of Ecuador’s secret service and with the knowledge of the ambassador. The Ecuadorean government has flatly denied spying on Mr. Assange.
Asked by the judge why his company had set up a remote access server to allow the transfer of information gathered within the embassy, Mr. Morales said that “there was absolutely no outside access.”
Mr. Morales is accused of bribing an embassy official, paying the official about $22,000 monthly to send positive reports about UC Global’s surveillance work back to the authorities in Quito.
WikiLeaks gained worldwide attention in 2010, when it published a vast cache of classified material taken from American military computer systems, most of it about the wars in Iraq and Afghanistan.
That year, Swedish prosecutors sought to arrest and question Mr. Assange on sexual assault accusations, which he said were fabricated as a pretext for handing him to the United States. Mr. Assange, who was in Britain at the time, surrendered to the British police, posted bail and fought extradition to Sweden.
But in 2012, fearing that he would lose that case, he sought asylum in the Ecuadorean Embassy in London, and Mr. Correa’s government granted it. Mr. Assange stayed there for nearly seven years, skipping court appearances, forfeiting his bail and continuing to run WikiLeaks.
Recently, the Swedes dropped their investigation, saying that the evidence was too weak for a prosecution.
In 2016, WikiLeaks published stolen Democratic Party emails that damaged the presidential campaign of Hillary Clinton. Russian spies had hacked the party’s computers, according to Robert S. Mueller III, the special counsel, but Mr. Assange denies any link to Russian intelligence.
As Mr. Assange’s relations with his Ecuadorean hosts deteriorated, President Lenín Moreno, who succeeded Mr. Correa in 2017, pressured him to leave. In April this year, Ecuador revoked Mr. Assange’s asylum, and the British police arrested him. He was convicted of bail-jumping and sentenced to 50 weeks in prison.
Mr. Assange contends he is a journalist, publishing what he receives from his sources, and not responsible if they have obtained it illegally. The Obama administration reluctantly accepted that argument. The Trump administration rejects it, and charges that in addition, he aided the illegal 2010 hacking.
David D. Kirkpatrick contributed reporting from London, and Julian E. Barnes from Washington.