Ecuador bankrolled a multimillion-dollar spy operation to protect and support Julian Assange in its central London embassy, employing an international security company and undercover agents to monitor his visitors, embassy staff and even the British police, according to documents seen by the Guardian.

Over more than five years, Ecuador put at least $5m (£3.7m) into a secret intelligence budget that protected the WikiLeaks founder while he had visits from Nigel Farage, members of European nationalist groups and individuals linked to the Kremlin.

Last month, the Democratic National Committee filed a lawsuit against the Russian government, Donald Trump’s campaign and WikiLeaks, alleging a conspiracy to help swing the election for Trump.

Documents show the intelligence programme, called “Operation Guest”, which later became known as “Operation Hotel” – coupled with parallel covert actions – ran up an average cost of at least $66,000 a month for security, intelligence gathering and counter-intelligence to “protect” one of the world’s most high-profile fugitives.

An investigation by the Guardian and Focus Ecuador reveals the operation had the approval of the then Ecuadorian president, Rafael Correa, and the then foreign minister, Ricardo Patiño, according to sources.

The then Ecuadorian foreign minister, Ricardo Patiño, with Assange at the embassy in August 2014. Photograph: John Stillwell/WPA/Getty Images

Correa has defended the decision to give Assange political asylum and described the UK’s behaviour towards Ecuador as “intolerable”. Neither he nor the Ecuadorian government had any immediate comment.

From June 2012 to the end of August 2013, Operation Hotel cost Ecuador $972,889, according to documents belonging to the country’s intelligence agency, known as Senain.

Q&A

What would happen if Julian Assange left the Ecuadorian embassy?

Julian Assange has been in the Ecuadorian embassy in central London since August 2012. He initially sought asylum following a series of legal challenges through British courts to a European arrest warrant issued by Sweden, where he was accused of rape and sexual assault, which he denies.

In February, a judge upheld a warrant for his arrest for skipping bail, meaning that although Swedish prosecutors have dropped their investigation into alleged sexual offences, Assange faces being arrested if he leaves the embassy, and fears he would be subsequently extradited to the US for questioning about WikiLeaks’ activities.

Photograph: Frank Augstein/AP

Was this helpful?

Thank you for your feedback.

The agency used a “special expenses” budget to pay for CCTV cameras to be installed in the embassy weeks after Assange moved in.

At the same time, documents show an international security company was contracted to secretly film and monitor all activity in the embassy. The company installed a team who provided 24/7 security, with two people on shift at a time, based at a £2,800-a-month flat in an Edwardian mansion building round the corner from the Knightsbridge embassy.

How Julian Assange became an unwelcome guest in Ecuador's embassy

Read more

Even the then Ecuadorian ambassador to the UK, Juan Falconí Puig, seems to have been unaware of the operation until a council tax bill for the flat was posted to the embassy in May 2015. The arrangement had to be explained to the ambassador in a conference call with Patiño, according to a source.

The security personnel recorded in minute detail Assange’s daily activities, and his interactions with embassy staff, his legal team and other visitors. They also documented his changing moods.

The interior of the apartment in Basil Street, which cost £2,800 a month to rent and is round the corner from the embassy. Photograph: Chestertons

The team consulted Assange about each person seeking to visit him. Guests would pass through a security zone, leaving their passports with staff there, according to sources, and documents seen by the Guardian.

The passports were used to create a profile that described the visit and gave background details of all his visitors.

Worried that British authorities could use force to enter the embassy and seize Assange, Ecuadorian officials came up with plans to help him escape.

They included smuggling Assange out in a diplomatic vehicle or appointing him as Ecuador’s United Nations representative so he could have diplomatic immunity in order to attend UN meetings, according to documents seen by the Guardian dated August 2012.

In addition to giving Assange asylum, Correa’s government was apparently prepared to spend money on improving his image. A lawyer was asked to devise a “media strategy” to mark the “second anniversary of his diplomatic asylum”, in a leaked 2014 email exchange seen by the Guardian.

This included a joint press conference with him and Patiño in London, and the publication of an opinion piece for the Guardian. The fee including other costs would be $180,960 for a year’s media consultancy.

But the documents showed the way in which the relationship between Assange and his hosts deteriorated over time.

In an extraordinary breach of diplomatic protocol, Assange managed to compromise the communications system within the embassy and had his own satellite internet access, according to documents and a source who wished to remain anonymous. By penetrating the embassy’s firewall, Assange was able to access and intercept the official and personal communications of staff, the source claimed.

In tweets on Tuesday WikiLeaks denied that Assange had compromised the embassy’s network. “That’s an anonymous libel aligned with the current UK-US government onslaught against Mr Assange,” WikiLeaks wrote, adding that its editor-in-chief was not in a position to respond.

In 2014, the company hired to film Assange’s visitors was warning the Ecuadorian government that he was “intercepting and gathering information from the embassy and the people who worked there”.

The escalating cost of the Operation Hotel surveillance operation was also an issue for Ecuador’s financial controller’s office.

Assange talks with his then legal adviser, Baltasar Garzón, second right, inside the embassy in August 2012. Photograph: Sean Dempsey/PA

Carlos Pólit, the then comptroller general, wrote to the then intelligence chief, Pablo Romero, in March 2013, asking how $411,793 could have been spent on special expenses in five months without a single receipt.

More than half that amount – $224,699 – was spent on three undercover agents for Operation Hotel: a captain in the Ecuadorian navy, a colonel and a counter-intelligence operator. They were typically given monthly cash payments of about $10,000, according to official accounts, for services classified as “intelligence and counter-intelligence operations”.

Romero said documentation relating to “the security of our guest” needed to be kept to a minimum given the “high sensitivity of the case”.

Why does Ecuador want Assange out of its London embassy?

Read more

But the Operation Hotel outgoings were a fraction of the intelligence agency’s special expenses. In Assange’s first two months in the embassy, Senain spent $22.5m on 38 other operations with codenames including “undercover agents”, “counter-intelligence” and “Venezuela”, according to official documents.

Documents seen by the Guardian show Senain made multimillion-dollar payments to internet surveillance companies for spying software. One was Hacking Team, a cybersecurity company based in Italy.

Hacking Team did not respond to a request for comment. Documents show it was contracted directly or subcontracted through other companies by Senain between 2012 and 2015.

Lenín Moreno, the Ecuadorian president, is keen for Assange to leave the embassy in order to improve ties with the US. Photograph: Juan Ruiz/AFP/Getty Images

It is unclear how the Ecuadorian government used the surveillance tools. But investigative journalists working in Ecuador say they have often been forced to move their websites abroad to avoid cyber-attacks and hacking attempts. Others have been prosecuted through the courts. Facing fines and criminal charges, some were forced into exile.

Ecuador’s president, Lenín Moreno, shut down Senain in March in response to what he called the “ethical outcry of citizens”.

He said the move was intended to “guarantee the security needs of the country”, in what appeared to be a pointed reference to the resources the agency had dedicated to protecting a person who had very little to do with Ecuador’s security.

Ecuador’s comptroller is investigating how Senain spent $284.7m between 2012 and 2017, the majority of it on special expenses such as activities connected to Assange. About 80% of the overall budget went on such expenses last year, according to a statement on the comptroller’s website.

This article was written in collaboration with Fernando Villavicencio and Cristina Solórzano from Focus Ecuador