LONDON — Ecuador and Sweden have agreed to allow Julian Assange to be questioned by Swedish prosecutors inside the Ecuadorean Embassy in London, in a possible breakthrough to a four-year impasse, Ecuador said on Thursday, but no date for the interview was announced.

The Ecuadorean attorney general delivered a document agreeing to a request by the Swedish prosecutor to question Mr. Assange, the founder of WikiLeaks, who is wanted by Sweden for questioning to respond to allegations of rape made against him, accusations he denies.

Mr. Assange was granted political asylum by Ecuador in 2012 after his appeal against extradition to Sweden was denied, and he has been confined to the embassy ever since. He says he fears that if he is sent to Sweden, he will then be shipped to the United States, where he could be charged with espionage offenses.