Zambia's President Edgar Lungu has been re-elected, according to official results, which are being challenged by the main opposition party.
The electoral commission said Mr Lungu had secured 50.35% in Thursday's vote, just over the 50% threshold needed to avoid a second round under a new electoral system.
His main rival, Hakainde Hichilema, who alleges electoral fraud, won 47.67%.
Earlier, his UPND party withdrew from the ballot verification process.
Zambia's shifting political allegiances: Nomsa Maseko, BBC News, Lusaka
Zambia's capital Lusaka has been brought to a complete standstill.
Thousands dressed in the green and white of the Patriotic Front are celebrating on the streets of the city.
Some are carrying makeshift coffins with opposition leader Hakainde Hichilema's name on them.
But the declaration by Zambia's electoral commission announcing Edgar Lungu as president-elect wasn't welcomed by all.
Mr Hichilema described this election as a sham which did not reflect the will of the people.
He plans to petition the constitutional court to challenge the result. He may well be going at it alone because of the fluidity of Zambia's political landscape.
The shifting of political allegiances, which in other parts of the continent would be seen as a betrayal, would mean those who left the Patriotic Front may go back to President Lungu, begging to have their old positions back.
The UPND has accused the electoral commission of colluding with the governing Patriotic Front (PF) to rig the result.
"We have evidence to the effect that the votes for Hakainde Hichilema have been deliberately reduced in collusion with the Electoral Commission of Zambia," UPND lawyer Jack Mwiimbu told journalists.
"We have confidence that the constitutional court will rise above board and declare the results a nullity."
The PF has rejected the allegations.
Election officials also denied the fraud claims, saying the slow publication of the results was because there were five different votes on Thursday - for president, parliament, mayors, local councillors and an amendment to the constitution on changes to the bill of rights.
Mr Lungu defeated Mr Hichilema in the previous election, last year, by less than 28,000 votes. This time, his margin of victory was about 200,000 votes.
Last year's election was held because President Michael Sata died in office, the second time a serving leader has died in Zambia in the past five years.
The constitution has now been amended so that the vice-president automatically takes office if a sitting president dies.
Zambia's election rivals:
Edgar Lungu - Patriotic Front (PF)
- The 59-year-old lawyer became president in January 2015 in an election called after the death in office of President Michael Sata
- He served in Mr Sata's government as minister for justice and defence
- Support base: Home area of Eastern province, the capital, Lusaka, and the Copperbelt plus the Bemba-speaking regions
- Known for ordering a national day of prayer last year to help combat the economic problems facing the country
- Married with six children, this vote is seen as a personal referendum on him
Hakainde Hichilema - United Party for National Development (UPND)
- The 54-year-old economist has contested nearly all elections in Zambia since 2006
- A wealthy businessman, he has a solid track record in the private sector
- Support base: Home region of Southern Province and is popular with younger voters
- Known for being Zambia's second largest cattle rancher
- Commonly referred to by his initials HH, he is married with three children