KHARTOUM (Reuters) - Sudanese authorities and U.S. officials in Khartoum are negotiating to allow a Sudanese woman, who married an American and was recently spared the death penalty for converting to Christianity, to leave Sudan, sources close to the case said.

Mariam Yahya Ibrahim, 27, was detained at Khartoum airport Tuesday, a day after an appeals court overturned a death sentence imposed on her for having converted from Islam to Christianity to marry her Christian American husband.

Her lawyer Mohaned Mostafa said Ibrahim, her husband and two children had all been staying at the U.S. embassy in Khartoum since her release, which was granted on the condition that Ibrahim remains in Sudan.

"There are talks going on currently between Sudanese and American officials to try to find a way for Mariam and her family to leave the country," a source close to the case said, asking not to be named as he was not authorised to talk to the media.

Ibrahim was detained Tuesday for trying to use documents issued by the embassy of South Sudan to fly out of Khartoum with her American-South Sudanese husband and their two children.

Despite lifting her death sentence after huge international pressure, Sudan still does not acknowledge Ibrahim's new identity as a Christian South Sudanese because it does not recognize her marriage. Muslim women are not permitted to marry Christian men under the Islamic laws that Sudan applies.

"The talks now are aiming to get her out of Sudan on a Sudanese passport," the source said.

Ibrahim's husband Daniel Wani told Reuters that it was a "misunderstanding" and error when Sudanese authorities said her travel documents were invalid, adding his wife should have the right to adopt his South Sudanese nationality.

"There is diplomatic work going on and the Sudanese government offers help and cooperates in this matter," Wani said in a phone conversation with Reuters. "We will leave this time in a smooth manner and with travel documents that the Sudanese authorities accept."

South Sudan, which has a majority Christian population, became independent from the mostly Muslim north after a referendum in 2011 that ended years of civil war.

Ibrahim's case has been closely monitored by Washington and London, which last month summoned the Sudanese charge d'affaires to protest against Ibrahim's initial death sentence and urged Sudan to uphold its international obligations on freedom of religion and belief.

A U.S. spokeswoman said on Thursday before Ibrahim's release that Ibrahim had all the documents she needed to travel to the United States.

The United States has imposed economic sanctions on Sudan since 1997 over alleged human rights violations. It intensified sanctions in 2006 over Khartoum's actions in its conflict with rebels in the western region of Darfur.