Sandiford, from Cheltenham, Gloucestershire, had faced the threat of execution by firing squad during her sentence in Indonesia.

Shahabadi, 35, had been serving a life sentence after being convicted of drug smuggling and both British prisoners are said to have been suffering from health problems.

The Indonesian minister for law and human rights, Yusril Ihza Mahendra, said he had signed a deal with British foreign secretary Yvette Cooper for the transfer of the pair.

“We agreed to grant the transfers of the prisoners to the UK. The agreement has been signed,” Mr Yusril told reporters at a press conference in capital Jakarta earlier.

They will be handed over after the technical details of the transfer are agreed, which the minister said could take “around two weeks” to organise.