An attempt to extradite Julian Assange to Sweden has suffered a setback after a court in Uppsala said he did not need to be detained.

The ruling by the district court prevents Swedish prosecutors from applying immediately for an extradition warrant for Assange to face an allegation of rape dating back to 2010. Assange denies the accusation.

Assange is serving a 50-week sentence in Britain for skipping bail after he spent seven years in the Ecuadorian embassy in London attempting to avoid extradition to Sweden.

Swedish prosecutors dropped their rape investigation in 2017 but reopened it after Ecuador rescinded its grant of asylum to Assange in April this year and allowed British police to arrest him.

The 47-year-old Australian was too ill to appear last week at the latest hearing at Westminster magistrates court in relation to a rival US extradition request.

US government lawyers are seeking his removal to the US where he is charged with conspiracy to commit computer intrusion, which carries a maximum penalty of five years. He also faces additional charges of violating the Espionage Act by publishing classified information through WikiLeaks.

If both Sweden and the US present competing extradition requests, it will be up to the UK home secretary, Sajid Javid, to decide which application takes priority.

At the Swedish court on Monday, a judgment was read out saying that since Assange was already in a British prison he did not need to be formally detained to be questioned by Swedish prosecutors.

“As Julian Assange is currently serving a prison sentence, the investigation can proceed with the help of a European investigation order, which does not require Julian Assange’s detention (in Sweden). The court therefore does not find it proportional to detain Julian Assange,” the judgment said.

Assange’s Swedish defence lawyer, Per Samuelson, argued that Assange’s imprisonment in Britain meant there was no flight risk. “He is in prison for half a year at least, and he is detained on behalf of the United States. So there is no point detaining him in Sweden too,” Samuelson said.

Responding to the ruling, the Swedish prosecutor Eva-Marie Persson said: “The investigation continues with interviews in Sweden. I will also issue a European investigation order in order to interview Julian Assange. No date has been set yet. We will constantly review the state of the investigation.”

Before the judgment, the prosecutor confirmed that if the court granted her request she intended to issue a European arrest warrant for Assange “concerning surrender to Sweden”.