A Sudanese woman whose death sentence for renouncing Islam was overturned has been released from jail again, after she was detained at Khartoum airport on Tuesday.
Meriam Ibrahim's lawyer, Muhannad Mustafa, said that she was currently in the US embassy with her family.
Mrs Ibrahim had been detained on charges of falsifying ID documents.
She was first released on 23 June when an appeals court lifted her death sentence for renouncing Islam.
Her sentencing in May to hang for apostasy sparked an outcry at home and around the world.
Mrs Ibrahim, 27, had been held at a police station in the capital, since Tuesday, when she was prevented from leaving the country along with her husband, Daniel Wani, and their two children.
Daniel Wani is a Christian from South Sudan and is a US citizen.
She had reportedly planned to travel to the US with her family.
According to Reuters news agency, quoting her lawyer, Mrs Ibrahim was released on the condition that she remains in Sudan.
"Mariam was released after a guarantor was found, but, of course, she would not be able to leave the country," Mr Mustafa said.
"I would like to thank the Sudanese people and the Sudanese police," she told the BBC in an exclusive interview as she left custody. "I would like to thank those who stood beside me."
Asked about her plans following her release, she said: "I will leave it to God. I didn't even have a chance to see my family after I got out of prison."
She has been charged with forgery relating to the South Sudanese travel document she was carrying, and accused of providing false information.
South Sudan's embassy in Khartoum says the emergency travel documents were issued by the South Sudan authorities and are genuine.
However, Sudanese officials say she should have used a Sudanese passport and on Wednesday Sudan's foreign ministry summoned the US and South Sudan charges d'affaires over the issue.
The ministry criticised South Sudan for issuing travel documents "despite their knowledge that she is a Sudanese national" and condemned the US for trying to help the woman leave Sudan using an "illegal [false] travel document", the Suna news agency reports.
Sudan's National Security and Intelligence Authority is reported to have lodged the complaint against Mrs Ibrahim.
BBC correspondents say that now Sudan's intelligence agency is involved, Mrs Ibrahim's case is likely to be more difficult and complicated to resolve.
Sudan has a majority Muslim population, and Islamic law has been in force there since the 1980s.
Born to a Muslim father, Mrs Ibrahim married Mr Wani in 2011.
Even though Mrs Ibrahim was brought up as an Orthodox Christian, the authorities considered her to be a Muslim because of her father's religion.
At her trial in May in the capital, Khartoum, a judge also sentenced Mrs Ibrahim to 100 lashes for adultery because her marriage to a Christian man was not valid under Islamic law.