What you need to know:
- His rival Hakainde Hichilema of the United Party for National Development garnered 46.67 per cent.
- Lungu will be sworn in on Sunday, becoming Zambia's sixth president since independence from Britain.
Zambia's defence minister Edgar Lungu, of the ruling Patriotic Front, has narrowly won the country's presidential race, the electoral commission announced Saturday after an election marred by delays.
Lungu won 48.33 per cent of the vote, beating his rival Hakainde Hichilema of the United Party for National Development (UPND), who garnered 46.67 per cent.
Lungu's victory was greeted with cheers and dancing after the chairwoman of the Electoral Commission of Zambia, Ireen Mambilima, announced the results of this week's vote, which Hichilema has denounced as a sham.
Some of the celebrations in the streets of capital Lusaka got out of hand, with police using teargas to disperse excited PF supporters who tried to force their way into the conference centre where the announcement was made.
Neither Lungu nor Hichilema attended the announcement of the results of the race for the year-and-a-half term left when former president Michael Sata died in office last year.
Patriotic Front secretary general Davies Chama applauded Lungu's victory, saying he had worked hard to win support.
Lungu will be sworn in on Sunday, becoming Zambia's sixth president since independence from Britain.
The tall, slim former lawyer, who describes himself as an "ordinary Zambian of humble beginnings", was relatively unknown before Sata died in October.
The 58-year-old fought a bruising internal power struggle to become the ruling Patriotic Front's candidate against a party faction backed by interim president Guy Scott.
"I want to form a government which will be very inclusive," he told AFP in a recent interview, promising to reach out to opposition politicians and even those within the PF who "viciously" opposed his candidacy.
Lungu has promised political stability and to continue programmes introduced by Sata, including a contentious resources tax that has put the government of the copper-rich southern African nation at loggerheads with miners.
He revealed his conservative side in 2013 when he said all gay rights advocates should "go to hell" after two homosexual Zambian men were arrested.
The presidential vote spilled into three days, from Tuesday to Thursday, with the opposition camp alleging irregularities.
Hichilema, a self-made businessman on his fourth run at the presidency, said the election had not been fair from the start, and condemned violence against his backers ahead of the vote.
"We have experienced widespread violence against our supporters and party members throughout the campaign, as well as deep irregularities in the counting process," he said on Saturday before the election results were announced.
Hichilema alleged there were discrepancies in the counting process, and demanded the commission verify the results in the presence of officials from his party and the ruling PF.
Scores of his backers stormed the electoral commission's offices on Thursday, claiming vote-rigging.
Nevertheless Hichilema urged his supporters to remain calm "for the sake of Zambia", and vowed his party would emerge stronger ahead of general elections in 2016.
The election was also marred by poor voter turnout amid heavy downpours of rain.
Acting president Scott will officially step down on Sunday when Lungu is sworn in.
Scott, Africa's first white leader in 20 years, could not stand for the presidency as his parents were not born in Zambia.