Voters picked Hakainde Hichilema, a businessman who had lost five previous bids for the job, to take over from Edgar Lungu, who has led the southern African nation since 2015.JOHANNESBURG — The leader of Zambia’s main opposition party sailed to victory in the nation’s presidential election, according to results announced on Monday, staving off strong-arm tactics from the incumbent governing party that had stoked fears of a rigged vote.The opposition leader, Hakainde Hichilema, a businessman who had lost five previous bids for the presidency, captured more than 2.8 million votes in the election, which was held Thursday, unseating Edgar Lungu, who drew 1.8 million votes. Mr. Lungu had governed the southern African nation since 2015.Analysts saw the victory by Mr. Hichilema, 59, who leads the United Party for National Development, as a resounding rebuke of Mr. Lungu’s shepherding of an economy that was in tatters. Zambia, a copper-producing nation, has been marred by huge inflation, stifling debt, rising food prices and unemployment.On top of the economic problems, activists and opposition politicians warned that increasingly repressive tactics from Mr. Lungu’s government would cause an erosion of the country’s democracy, which was seen as a model across the continent after Zambia’s founding father, Kenneth Kaunda, reluctantly stepped aside when he lost the first multiparty elections in 1991.Mr. Hichilema, in a written statement provided to The New York Times by Vanguard Africa, a pro-democracy nonprofit that is working with him, said, “In the 2021 elections, the people voted to save democracy.”“We know that a healthy and functioning democracy is one in which the voices of citizens can be heard freely,” he added. “We will listen to those voices rather than seeking to silence critics.”Ahead of the election, irregularities in voter registration led to a greater number of people on the rolls in areas that historically favored Mr. Lungu’s party, the Patriotic Front. The government cracked down on Mr. Hichilema’s ability to campaign, in some cases blocking his travel. And activists accused the government of rights abuses in violently squashing opposition demonstrations and of trying to stifle critical independent media.Even during the voting, the government deployed the military to the streets, citing attacks on Lungu supporters, and it restricted access to social media sites, a decision that a court quickly overturned.Despite all of the challenges, Mr. Hichilema won decisively.President Edgar Lungu of Zambia at the United Nations in 2018. Activists accused his government of rights abuses in violently squashing opposition rallies and of trying to stifle critical news media.Eduardo Munoz/ReutersZambians were “anxious about the possibility of another five years under such a dysfunctional regime,” said Laura Miti, director of the Alliance for Community Action, a nongovernmental organization based in Lusaka, the Zambian capital, that works on public accountability. That made people even more vigilant in the face of the Patriotic Front’s efforts to sway the election toward Mr. Lungu, she said.“I think, in a way, the attempts to subvert the election worked against them,” Ms. Miti said. “I think more people turned out.”Although voter registration was higher in Mr. Lungu’s traditional bases of support, turnout there was lower than in the regions that tended to favor Mr. Hichilema, analysts said. And Mr. Hichilema’s party generally lost by narrow margins in Mr. Lungu’s strongholds, while winning handily the constituencies most favorable to him.As the first rounds of election results were released, Mr. Lungu issued a statement declaring that the voting was “not free and fair.”He claimed that violence at polling stations on Thursday had kept his supporters away. Mr. Lungu posted a lengthy thread on Twitter condemning the killings of two of his supporters and railing about the effect that he said it was having on the elections.Mr. Lungu’s Twitter feed leading up to the voting has been laced with calls for prayer and images of infrastructure projects during his tenure as he sought to portray his re-election as necessary to continue that progress. But that messaging stood in contrast to the everyday realities of Zambians, said Nicole Beardsworth, a lecturer at the University of the Witwatersrand in Johannesburg who has been in Zambia since early last month studying the election.“I heard this from a lot of people that, ‘You can’t eat the roads,’” she said. “And what point is a school if you don’t have a teacher, and what’s the point of a clinic if you don’t have medicine? That was really the thing that turned the election against the P.F. and against Lungu.”A campaign poster for Mr. Lungu on a tree in downtown Lusaka on Sunday. As the first rounds of election results were released, he issued a statement declaring that the vote was “not free and fair.”Marco Longari/Agence France-Presse — Getty ImagesIn his statement, Mr. Hichilema said that, while it would take time to get the economy headed in the right direction, Zambians could expect to see immediate changes in transparency and governance.“We will not bring the military out on the streets,” he said. “We will not arrest civil society activists speaking out in the interests of the people. And we will act quickly to stop the plunder of state resources.”Ms. Miti said that with Mr. Hichilema’s margin of victory and support from Parliament members outside his party, he could govern with a two-thirds majority — the level of support required to make constitutional changes. In the past, presidents have tried to change the Constitution to their benefit. It will be up to Zambians now to hold him accountable, she said.“The question is: What does he do with that power?” Ms. Miti said. “If citizens go to sleep and say, ‘Well, we’ve done our part,’ then you could easily create another regime that either becomes tyrannical or rules in self-interest.” More