Zambian President Rupiah Banda has conceded electoral defeat to opposition leader Michael Sata.
Mr Sata, who has run for the presidency four times, was declared the winner overnight after polling 43% of the vote.
"The people of Zambia have spoken and we must all listen," Mr Banda told journalists, wiping away tears after finishing his speech.
His Movement for Multiparty Democracy has ruled Zambia for 20 years.
"Speaking for myself and my party, we accept the results. We are a democratic party and we know no other way," Mr Banda said.
On Thursday, there had been riots in the country's northern mining region by opposition supporters impatient for the results of Tuesday's polls.
The results were declared with seven constituencies still outstanding, but electoral officials said Mr Banda would not be able to catch up with Mr Sata's lead.
The BBC's Louise Redvers in the capital, Lusaka, says with the declaration, the tension in the results centre dissolved into screams as the Patriotic Front supporters celebrated their win.
Thousands of people flocked outside the heavily guarded gates banging drums, beeping horns and waving flags.
'Man of action'
"We want change - especially for the youth," one woman celebrating on the streets of Lusaka told the BBC.
Another reveller described Mr Sata as a "man of action".
"We've looked forward to this for a long time," he said.
Mr Sata, who reportedly used to sweep floors at London's Victoria Station, has had a lengthy career in politics and is due to be sworn in later on Friday.
He served as an MMD minister for local government, labour and social security, and health before quitting in 2001.
Known as "King Cobra" for his venomous tongue, he has frequently criticised foreign mining firms - often from China - about labour conditions.
While the party has disputed media reports that it is anti-Chinese, his election is likely to shake up the way contracts are awarded, our correspondent says.
There were suggestions Chinese firms were bankrolling Mr Banda's re-election campaign in the run-up to the poll, with PF candidates expressing surprise at the amount of funds available to the MMD. But MMD officials have said the funds were raised through legitimate donations.
International observers had also criticised the MMD for abusing state resources during its campaign and noted media bias on the part of the state broadcaster.
But in his outgoing speech, Mr Banda rejected the allegations.
"We never rigged, we never cheated, we never knowingly abused state funds. We simply did what we thought was best for Zambia," he said.
He urged Zambians stands to stand together and "rally behind your new president".
"Yes, we may have different ideas, but we both want the same things - a better Zambia.
"Now is not the time for violence and retribution. Now is the time to unite and build tomorrow's Zambia together."
During the campaign, Mr Banda had highlighted the economic growth largely spurred by Chinese investments and the government's decision to scrap a windfall tax of 25% on mining companies.
Mr Sata has promised to re-introduce the windfall mining tax and to promote policies that will bring greater benefit to poor people.
More than 60% of Zambians live on less than $2 a day.