Ecuador’s president says his country and the United Kingdom are working on a legal solution for Julian Assange that would allow the Wikileaks founder to leave the Ecuadorian Embassy in London in “the medium term”.

President Lenin Moreno told The Associated Press that Mr Assange’s lawyers are aware of the negotiations. He declined to provide more details because of the sensitivity of the case.

Mr Assange has been holed up in the embassy for more than six years.

The famous whistleblower and computer engineer faces an arrest warrant in the UK and fears he could be extradited to the US, where high-level officials have spoken about prosecuting him for stealing classified information.

Mr Moreno says his country will seek to protect Mr Assange’s rights.

“Being five or six years in an embassy already violates his human rights,” he said, on the sidelines of the UN General Assembly. “But his presence in the embassy is also a problem.”

Ecuador’s previous left-leaning administration gave Mr Assange asylum in 2012, saying it feared his life was in danger for publishing thousands of diplomatic cables that put US officials in a difficult position.

But Mr Assange’s relationship with the Ecuadorian government has soured since the centrist Mr Moreno became president.

Over the past two years Mr Assange’s access to the internet was suspended on several occasions, as he continued to publish material from the hacked accounts of politicians from different countries and made controversial statements on his social media accounts.

“I understand that currently he has no access (to the internet) to stop him from doing that again,” Mr Moreno said. “But if Mr Assange promises to stop emitting opinions on the politics of friendly nations like Spain or the United States then we have no problem with him going online.”

Ecuador’s government has said Mr Assange’s activities in the embassy, including the publishing of thousands of Hillary Clinton’s emails prior to the 2016 election in the US, have compromised its relations with other countries.

“I don’t agree with what he does,” Mr Moreno said. “To see someone violating people’s right to communicate privately makes me feel uncomfortable.”

Mr Assange has long argued that he is simply monitoring the actions of some of the world’s most powerful politicians and exercising his right to free speech.