An appeals court has ruled Nigerian leader Olusegun Obasanjo did not have the power to sack his vice-president for joining an opposition party.
The vice president campaigned against a third term for President Obasanjo
The court in the capital, Abuja, ruled Atiku Abubakar should remain in his post despite his defection to the Action Congress for presidential polls.
In December, President Obasanjo's spokesman announced Mr Abubakar had "technically resigned" as a result.
He also asked the ruling People's Democratic Party to find a replacement.
"The president has no power under the constitution... to declare the office of the vice-president vacant," Justice Umaru Abdullahi said in his ruling.
Mr Abubakar's spokesman Garba Shehu immediately hailed the verdict, describing it as "a huge relief and a demonstration of the fact that the judiciary works in Nigeria".
"The president should go and bury his head in shame. He has lost all the cases he instituted against the vice-president."
The ruling is to be challenged in Nigeria's Supreme Court.
It is the latest twist in a long-running political struggle between the two men, after Mr Abubakar blocked the president's attempt to stand for a third term in the forthcoming presidential election in April.
After Mr Obasanjo's December announcement, Mr Abubakar headed for the law court to challenge the move.
The vice-president left the PDP after the country's anti-corruption agency and a ministerial panel reports accused him of corruption - charges he denies.
Two weeks ago, the Economic and Financial Crimes Commission listed Mr Abubakar among some 135 politicians it said were unfit to stand in the country's landmark general elections in April because they were corrupt.
The Court of Appeal decision means that Mr Abubakar cannot be arrested on corruption charges because it also means that he maintains constitutional immunity from prosecution.
But the vice-president still has other legal hurdles to cross as he is also in court challenging the government panel reports that accused him of corruption, says the BBC News website's Senan Murray in Abuja.