By Jonah Fisher
Former BBC Khartoum correspondent
President al-Bashir had been under huge pressure to intervene
Just over a week ago it was hard to imagine how the international reputation of the Sudanese government could sink any lower.
Accused of sponsoring the killing and rape of hundreds of thousands of its own people in Darfur and then of blocking the peacekeepers who might protect them - barely a week passed without a threat of sanctions or a new UN resolution.
But thanks to the Gillian Gibbons saga, Sudan has managed to transform its public image from pariah state to something approaching a laughing stock.
If Khartoum was hoping to turn the teddy bear into a rallying point for Muslims across the Middle East it was quickly disappointed.
Condemnation of the British teacher's detention came in from around the world and from all religions - leaving the government looking for an escape strategy.
The carefully stage-managed pardoning of Mrs Gibbons by Sudan's President Omar al-Bashir will have satisfied few within his divided government.
Moderates who want better relations with the West will want to know why Sudan's president did not intervene sooner.
Sudan's foreign ministry has been shown to be an open but ultimately powerless limb of the administration.
Sudanese officials reassured British diplomats that the case would be dismissed right up to the moment that Mrs Gibbons was sentenced to 15 days in detention.
That disconnect is an experience shared by UN officials who spent months negotiating with Sudanese diplomats the arrival of a new peacekeeping force for Darfur.
Those talks have since been shown to count for little. Security agencies have impounded equipment, denied permission for night flights and refused to grant land for military bases.
President al-Bashir is a military man, and Mrs Gibbons's detention has shown clearly once again that power rests firmly with security forces and the interior and defence ministries.
TEDDY ROW TEACHER TIMELINE
Sept: Gillian Gibbons's class votes to name a teddy bear Muhammad
25 Nov: She is arrested for allegedly insulting Islam's Prophet
27 Nov: Gordon Brown says efforts are being made to release her
28 Nov: Mrs Gibbons is charged with insulting religion and inciting hatred
29 Nov: A Sudanese court finds her guilty of insulting Islam and sentences her to 15 days in prison and deportation
30 Nov: Angry protesters in Khartoum demand a harsher sentence
1 Dec: Two British Muslim peers press Sudanese officials to pardon her
3 Dec: Mrs Gibbons is pardoned by Sudan's president and freed from prison
The men who lead these organs will not have minded the outcry in Britain. For them the key international relationship is not with the West but the Far East and China.
Despite 10 years of sanctions and an ongoing war in Darfur, Sudan's oil-fuelled economy is currently growing at one of the fastest rates in Africa.
British Prime Minister Gordon Brown's combative advocacy on Darfur may well have contributed to Mrs Gibbons's continued detention.
Mr Brown trumpeted his role in forcing through UN approval for a new peacekeeping mission and has infuriated Khartoum by regularly threatening further sanctions.
The arrest of Mrs Gibbons must have seemed like an easy opportunity to give their former colonial masters a bloody nose.
In practice, it appears to be the Sudanese president who has been left with a red face.