The government of Ecuador scuppered a deal this summer between Julian Assange and Swedish prosecutors that could have ended their three-year standoff over rape allegations, leaked documents show.

Assange and the Swedish director of public prosecutions, Marianne Ny, had apparently agreed that prosecutors could take DNA swabs and interview Assange on two days in June, but the meetings never took place because Ecuador raised numerous additional conditions or concerns.

The revelations also show Sweden casting private doubt on Ecuador's public pronouncements that it is seeking to solve the long-running diplomatic impasse its asylum offer to Assange has caused, and raise questions as to its reasons for stalling such a deal.

Lawyers acting for Assange revealed on Thursday that he had appealed to be able to leave the embassy for diagnostic tests on an injured shoulder, but this request was denied by UK authorities.

Assange fled to the Ecuadorian embassy in 2012, when he faced imminent extradition to Sweden to answer allegations of rape and sexual assault from two women, and was granted asylum on the grounds he was a political target of an alleged US prosecution. The USA has made no public attempt to extradite Assange.

The details of the deal between Sweden and Assange are revealed in an email sent by Ny to Ecuador's embassy in London on 8 June 2015, seen by BuzzFeed News.

Leaked Ecuadorian documents

The beginning of Marianne Ny's email to Ecuador's London embassy (email addresses redacted by BuzzFeed News).

"The request for permission, that last week was considered and accepted by the UKCA [UK Central Authority, a clearing house for EU law enforcement authorities], is made for a Swedish investigator from the police in Stockholm, whilst under the supervision of the Assistant Prosecutor, take a DNA sample from the suspect and conduct an interview with Julian Assange in London as well as conduct a complementary interview the following day," she wrote.

"The complementary interview may be cancelled should it be deemed unnecessary.

"By agreement with Julian Assange we want to conduct the investigation matters on two consecutive days during June-July 2015, and primarily in June 2015. Julian Assange has suggested 17-18 June 2015 to which we have agreed."

Ny then proceeded to ask the embassy officials to help with the practical matters of arranging the interview.

"Given that your government accepts my request for legal assistance in this matter," she wrote, "would it from a practical view be possible to carry out the investigative measures June 17th-18th in premises of the Embassy?"

Ecuador, however, proved less willing to help than Ny expected. Internal emails discussing the country's formal response to Sweden show the country throwing up a series of barriers against enabling the interview to take place, with advisers suggesting it was important the country was seen to win the diplomatic tussle and for Sweden to acknowledge Assange's asylum status – neither Sweden nor the UK legally acknowledge diplomatic asylum.

Ecuador even insisted that Sweden should sign a specific treaty over its bid to resolve the Assange situation, rather than either signing a general treaty agreeing the two countries would assist each other on criminal matters or just cooperating through informal channels.

In a terse formal diplomatic exchange seen by BuzzFeed News, Sweden rejected this request as "redundant".

"The Ministry of Justice notices that Ecuador maintains its position that a specific agreement must be undertaken between Sweden and Ecuador in order for Ecuador to grant legal assistance in accordance with the Swedish request," it said.

"The Ministry of Justice can only reiterate that it is not customary to establish a specific agreement concerning any individual request for legal assistance. Such an agreement must be considered redundant, given the specified content of the Swedish request and common practices"

The Swedish communiqué then hardened its position.

"The Ministry of Justice kindly asks once more Ecuador to reconsider its position," it states. "If not, the Ministry of Justice would have to conclude that Ecuador is not prepared to grant the legal assistance requested by Sweden."

Leaked Ecuadorian documents

The header of Sweden's official communication to Ecuador, in which it suggests it may have to conclude Ecuador is "not prepared" to assist with Assange's questioning.

One specific concern set out by Ecuador was its insistence to be in the room if Swedish prosecutors did meet with Assange. In her memo, Ny's proposal was for a Swedish police officer, a prosecutor, and a translator to meet Assange, his lawyer, and an advocate he had requested.

However, Ecuador appeared unwilling to allow any such meeting to take place without also being in the room itself.

"Ecuador, however, believes that in addition to these people, a diplomatic or consular official must be present," one email noted.

The standoff – and unwillingness to allow a private meeting – reflects the soured relations between the WikiLeaks chief and his Ecuadorian hosts.

BuzzFeed News previously reported on tensions between Assange and staff in the embassy, but new documents reveal animosity towards their most famous asylee runs as high as president Rafael Correa himself.

In a short email from July this year, Correa forwarded a press clipping to his foreign minister relating to Ecuador's commissioning of the private contractor Hacking Team for surveillance. Ecuador has repeatedly denied engaging the company, despite the leaked documents.

Other senior officials within Ecuador were wary from Assange from the beginning, as a series of 2012 emails between Alexis Mera – legal secretary to the president of Ecuador – and a correspondent reveal.

"For now we are happy with the situation with Assange," Mera noted in an opening email from his official presidential address. "The British have looked like idiots when they threatened to expel us from the embassy. I would like to know your impressions."

His correspondent struck a far more cautious note.

"You seem pleased with the Assange situation," he wrote. "I agree with you that the Brits have really screwed up with that threat. And moreover I think you all have very skillfully handled the issue of South American diplomatic support (which without that blunder would probably have been more difficult).

"But after the first few days of 'success' it is not going to be that easy. I think Ecuador has much to lose if the issue goes on too long, and also if the positions start to fester. But mostly I think Assange does not care about international law or the nature of the right to asylum, and he is untrustworthy.

"He has his interests and his agenda and will do what suits him at all times, including to the expense of his protectors."

Mera's reply was no-nonsense.

"I'm very clear about Assange. He is not part of this government nor is he with us. For now he has no choice but to pay attention to us. But if he fights with us, we will fire him off to jail in Sweden."

James Ball is a special correspondent for BuzzFeed News and is based in London.
PGP: here