A West African regional court has ordered Niger's junta to release President Mamadou Tandja, who they deposed in February, from house arrest.
Delivering a judgement in the Nigerian capital, Abuja, the Ecowas court said Mr Tandja's detention was illegal.
Mr Tandja has been in detention since his overthrow by the military. He had been strongly criticised for remaining in power for a third term.
Government lawyers said they would appeal against the judgement.
Voters in Niger last month back a new constitution designed to return the country to civilian rule.
It provides for elections in January and a transfer of power in April.
It also reduces the powers of future presidents and limits them to two terms in office.