Senegal's appeals court has said it does not have the power to decide if former Chad President Hissene Habre can be extradited to Belgium.
Hissene Habre denies murder and torture accusations
Belgium wants to try him on charges of mass murder and torture under his presidency, from 1982 to 1990.
Mr Habre - who fled to Senegal after he was ousted, and was arrested last week - denies knowledge of such atrocities.
One of his lawyers said Mr Habre would soon be freed but human rights lawyers insist the battle is not over.
"The court ... declares itself not competent in the case of the extradition of Hissene Habre," it said in a statement.
The court acted after receiving an international arrest warrant for Mr Habre, 63.
Defence lawyer Doudou Ndoye told Reuters news agency: "Senegal has shown that no African head of state will be prosecuted in Belgium".
He told reporters outside the court: "That's the end... our client is going to be freed".
But Reed Brody of New York-based Human Rights Watch, who has long campaigned for Mr Habre to be brought to trial, insisted: "The extradition case is still alive."
And Belgian lawyer Georges-Henri Beauthier told Reuters: "We're looking at the ruling and, contrary to what you might expect, the door is still open."
Human rights groups accuse Mr Habre's regime of some 40,000 executions and the torture of 200,000 people.
Efforts to prosecute Mr Habre in 2001 in Senegal failed after the country's highest court ruled he could not be tried there, as his alleged crimes were committed outside the country.
However, this time Mr Habre's alleged victims filed complaints under Belgium's universal jurisdiction law, which allows Brussels judges to prosecute human rights offences anywhere.
Human Rights Watch has led attempts to arrest Mr Habre, calling him "Africa's Pinochet".
Mr Habre's lawyers have argued that Belgium could not use a common law procedure to extradite their client.