|President Yahya Jammeh|
Long-ruling Jammeh lost the election to little-known businessman Adama Barrow on December 1 and conceded defeat in a widely celebrated moment of democratic hope for the continent.
But he has since changed his mind and his party is now challenging the outcome at Gambia's Supreme Court.
"For Mr Jammeh, the end is here and under no circumstances can he continue to be president," the UN's special representative Mohammed Ibn Chambas told Reuters news agency by telephone on Wednesday.
Chambas also told AFP news agency that "by January 19, he [Jammeh] should be ready to hand over power".
On Monday, Barrow had called for the president to step down "now" as his coalition became increasingly frustrated by Jammeh's refusal to admit defeat.
Jammeh has alleged that the election was rigged and called for a recount and fresh polls.
There are worries within the opposition camp that Jammeh could try to cling on to power pending the outcome of the legal case lodged on Wednesday by the ruling Alliance for Patriotic Reconciliation and Construction (APRC).
'Outrageous act of disrespect'
Chambas' spokesman had earlier told AFP that the security forces' ongoing occupation of Gambia's Independent Electoral Commission - the object of the APRC's legal complaint - was an "unacceptable act".
"It is a violation of the independent nature, guaranteed by the constitution, of the electoral commission, as some soldiers have taken away commission materials relating to the presidential election," the spokesman added.
UN Secretary-General Ban Ki-moon also condemned the government takeover of electoral offices, calling it an "outrageous act of disrespect of the will of the Gambian people and defiance towards the international community".
The electoral commission's chairman, Alieu Momar Njie, dismissed Jammeh's legal challenge of the election result as unworkable due to a lack of judges on the Supreme Court.
"The only way they can pursue the commission is through the court, and there is no court," Njie said.
To meet the January 18 deadline, he would need to appoint as many as six judges to the Supreme Court, which has laid dormant since May 2015. Lawyers continued a planned boycott of the court system on Wednesday in protest at Jammeh's legal fight.
The country's most influential lawyers' group, the Bar Association, said any appointment of judges by Jammeh to decide on a case involving himself would be fundamentally unjust.
Liberia's President Ellen Johnson Sirleaf said on Tuesday that a heavyweight delegation of four African leaders including herself had failed to reach a consensus with Jammeh and Barrow on a transition of power.
"We come to help Gambians find their way through a transition. That's not something that can happen in one day," said Sirleaf.
Al Jazeera's Nicolas Haque, reporting from Senegal, which borders Gambia, said that the visiting West African heads of state have left Gambia "empty-handed", without agreements or deals, despite serious efforts to persuade Jammeh to provide a smooth transition of power.