When Julian Assange, disguised as a motorcycle courier, first walked up the steps of Ecuador’s small embassy behind Harrods in central London and asked for asylum, few people – including, surely, Assange himself – could have imagined it would be almost seven years before he next exited the front door.

It was mid-June 2012, and as Britain expectantly awaited the opening of the Olympics just over a month later, the WikiLeaks publisher had exhausted every legal avenue in his attempts to avoid extradition to Sweden, where two women had made allegations of rape and sexual assault during a visit by Assange to Stockholm in 2010.

This video has been removed. This could be because it launched early, our rights have expired, there was a legal issue, or for another reason. Julian Assange removed from Ecuadorian embassy in London - video

Assange, who had been briefly imprisoned and then on bail for more than a year, argued that Swedish prosecutors should interview him in London. But as well as resisting extradition to Sweden, he also feared being handed over to the US for potential prosecution over the so-called Cablegate documents (published in the Guardian and elsewhere) and other releases. The WikiLeaks source Chelsea Manning was already in custody on espionage charges (she would be sentenced to 35 years in prison, later commuted by President Obama. Manning was reimprisoned last month).

Q&A Why was Julian Assange in the Ecuadorian embassy? Show Hide An arrest warrant for Assange was issued in August 2010 for two separate sexual assault allegations in Sweden. Police questioned him in Stockholm, where he denied the allegations. After returning to the UK, he feared that if he were extradited to Sweden he might be extradited on to the US, where he could face charges over WikiLeaks’ publication of secret US government files. In December 2010 he appeared at an extradition hearing in the UK, where he was granted bail. Following a legal battle, the courts ruled Assange should be extradited to Sweden. The WikiLeaks founder entered the Ecuadorian embassy in August 2012. He was granted political asylum, and remained there until his arrest. In May 2017, Swedish authorities dropped their investigations. However, the British police warrant for his arrest for skipping bail still remained. Lawyers for Assange failed in January 2018 to have the warrant torn up, arguing it had “lost its purpose and its function”. Scotland Yard has confirmed that Assange was arrested on behalf of the US after receiving a request for his extradition and the US has charged Assange with 'a federal charge of conspiracy to commit computer intrusion for agreeing to break a password to a classified U.S. government computer.' Jamie Grierson, Home affairs correspondent

Ecuador offered Assange almost his last option to avoid extradition, his last appeal having failed at the supreme court. The country’s then president, the leftwinger Rafael Correa, was sympathetic and Assange was granted asylum two months later.

It was never a very comfortable arrangement at the poky embassy, however. An office was repurposed as a bedroom and workspace, but he was forced, initially at least, to sleep on a mattress on the floor, sharing a bathroom and with access only to a tiny basic kitchen.

Facebook Twitter Pinterest Chelsea Manning has recently been reimprisoned on espionage charges. Photograph: Facundo Arrizabalaga/EPA

With the Swedes determined to extradite him, however, and a US grand jury hearing into WikiLeaks already under way, the Australian resolved to stay put. High-profile visitors came and went – Vivienne Westwood, Lady Gaga and the footballer Eric Cantona among them – and a small group of supporters maintained a periodic vigil outside. But still Assange remained.

Much has happened in the time he has been inside the embassy. WikiLeaks has continued to publish, exposing details of US tactics in trade negotiations, of the country’s surveillance of other governments, and of CIA hacking methods, among other revelations. A WikiLeaks staff member accompanied the whistleblower Edward Snowden to Moscow after he leaked classified NSA documents about US surveillance programmes to newspapers including the Guardian.

Assange has been the subject of a biopic starring Benedict Cumberbatch, which flopped, and a documentary, which premiered at Cannes. He even acquired a cat.

More significantly for the Australian’s legal position, after years of tortuous wrangling, his Swedish problem appeared to go away, thanks simply to the passage of time. An investigation into one of the Swedish women’s accusations, of sexual assault, was discontinued in 2015 after the statute of limitations expired, and in 2017, Sweden’s chief prosecutor said she was dropping her investigation into the outstanding allegation of rape after concluding there was no practical way of continuing. She gave herself the option of reopening the case if he later “made himself available”.

But even the apparent resolution of that seven-year legal standoff did not persuade Assange to leave the embassy, despite reports that the Obama administration had concluded it would not be able to prosecute him without pursuing the newspapers that had published WikiLeaks releases, including the New York Times and potentially the Guardian.

And, now that he has been removed from the embassy, the outstanding allegation of rape could be raised again if prosecutors decide to reopen the case. Elisabeth Massi Fritz, who represents his unnamed accuser, on Thursday told the Associated Press that “we are going to do everything” to have the case reopened “so Assange can be extradited to Sweden and prosecuted for rape”.

Assange’s Ecuadorian stay may have spanned two UK general elections (and two major referendums), but successive British governments have remained resolute, insisting that he would be subject to arrest if he left for alleged breaches of his bail conditions when he first sought asylum.

Facebook Twitter Pinterest Benedict Cumberbatch as Julian Assange in a scene from the biopic The Fifth Estate. Photograph: Frank Connor/AP

A finding by a UN panel in 2016 that Assange’s continued confinement in the embassy amounted to “arbitrary detention” was dismissed by the UK Foreign Office, which maintained that his presence there was voluntary.

Two significant things changed, however – both of them presidential elections.

Donald Trump was initially a great fan of Assange, praising WikiLeaks repeatedly during the 2016 presidential campaign after emails from the Democratic National Committee (DNC) and his rival Hillary Clinton’s campaign were published by the website. But other US Republicans have remained hostile, and following Trump’s election to the presidency, his administration has vowed to attempt to prosecute Assange.

Julian Assange: key dates in the WikiLeaks founder's case Read more

In February 2017 the then attorney general Jeff Sessions said arresting Assange was a priority, while a mistake in a document filed last November suggested criminal charges had been secretly filed against him. Trump and Sessions’s successor, William Barr, now have the yet-to-be-published report by special counsel Robert Mueller into Trump’s links to Russia, including allegations that the DNC releases published by WikiLeaks were obtained by Russian hackers.

But aside from events in the US, Assange has also had an increasing Ecuadorian problem. WikiLeaks’s DNC publications in 2016 prompted Ecuador’s discomfort at its sometimes troublesome houseguest to flare into irritation, and it temporarily cut off the Australian’s internet access saying he was using it to interfere in the US election.

Facebook Twitter Pinterest Julian Assange speaks to reporters and supporters on a balcony of the Ecuadorian embassy, London, May 2017. Photograph: Xinhua/Barcroft Images

The relationship between Assange and his hosts deteriorated further after Lenín Moreno was elected to the Ecuadorian presidency in 2017. Moreno had described Assange as a “stone in the shoe”, but said before his election that he could remain in the embassy if he agreed to abide by certain conditions.

In January 2018 it emerged that the country had made Assange an Ecuadorian citizen in a bid to resolve the impasse (its request to have him recognised as a diplomat was dismissed by the UK).

But the Ecuador-Assange relationship remained strained, and last year the country cut off his internet access again, saying he had breached an agreement not to interfere with other states. Assange had tweeted in support of the Catalan independence movement, causing a rift between Quito and Madrid, and challenged the UK’s accusation that Russia was responsible for the poisoning of a Russian former double agent Sergei Skripal and his daughter, Yulia.

Moreno later ordered the removal of an additional multimillion-pound security operation set up by his predecessor to protect Assange. In July last year the president said that Assange would ultimately have to leave the embassy, and by October the Australian was suing his hosts, saying their conditions for his stay violated his “fundamental rights and freedoms”. On Wednesday, WikiLeaks held a press conference to say it had uncovered a surveillance operation against him in the embassy, leading to private legal and medical information being offered for sale in what it said was an extortion attempt.

On Thursday morning, finally, Ecuador’s patience had “reached its limit”, Moreno said in a statement justifying his decision to revoke Assange’s asylum status. He is now, once again, in British custody.

• This article was amended on 12 April 2019 because an earlier version referred to years of torturous wrangling, when tortuous wrangling was meant. This has been corrected.