Zambia’s high court has declared that Defence Minister Edgar Lungu is the governing party’s presidential candidate in next month’s election.
The Patriotic Front (PF) party has been split over who will succeed President Michael Sata following his death.
One faction chose Mr Lungu as the party’s candidate while another opted for economist Miles Sampa.
The split could open the way for the opposition to take power in the elections, analysts say.
The rival PF factions held separate conferences over the past week to elect a leader and presidential candidate for the 20 January election.
Mr Lungu’s faction challenged Mr Sampa’s nomination in court.
“The purported general conference of 1 December at which the said honourable Miles Sampa was elected as another party president of the Patriotic Front be declared illegal, null and void and all decisions made thereof are quashed,” the judge ruled.
Mr Sampa said he would appeal against the ruling.
He is allied to Zambia’s interim President Guy Scott, who took office after Mr Sata died in a UK hospital in October at the age of 77.
Mr Scott has played a key role in the power-struggle, suspending Mr Lungu as PF secretary-general shortly after Mr Sata’s death.
He was forced to reinstate Mr Lungu a day later following an outcry in the party.
Mr Scott, who is ineligible to run for the presidency, is trying to play the role of kingmaker, some analysts say.