NAIROBI, Kenya — President Yoweri Kaguta Museveni of Uganda has won a sixth term, the country’s electoral commission said on Saturday, after a campaign marred by a lethal crackdown on the opposition, an internet blackout and accusations of vote tampering and rigging.
The result gives Mr. Museveni, who came to power in 1986 and is one of Africa’s longest-serving leaders, a new five-year term. It also caps a bitter and bloody campaign for his opponents — particularly his main rival, the musician-turned-lawmaker Bobi Wine.
Mr. Wine was beaten and bruised, his entire campaign team was detained and his home was surrounded and breached by the military. On Saturday, Mr. Wine challenged the results, saying Mr. Museveni’s government had “fabricated” them.
“We rejected what they are putting out,” he said in a telephone interview from Kampala, the capital. “We have our evidence, but they are keeping the internet shut down so that we don’t communicate it to the world,” he said, of the blackout that began in the day before the Jan. 14 election. “We won,” he added.
Under Mr. Museveni, Uganda has proved to be a close Western military ally in East Africa, with troops serving as peacekeepers in Somalia, where the authorities have long battled the Qaeda-linked group al Shabab. Ugandan recruits have also served as private security guards and worked closely with American troops in Iraq and Afghanistan.
Mr. Museveni’s deep Western political and military ties have for years cushioned him from direct criticism, even as human rights groups criticized his crackdown on pro-democracy movements.
The electoral commission said Mr. Museveni received more than 5.8 million votes, or 58.6 percent of the total votes, while Mr. Wine received 3.4 million votes, or over 34 percent of the total votes. There were 18.1 million registered voters out of a population of about 45 million.
Although Ugandan opposition candidates have faced crackdowns in the past, “the gag during this election was unprecedented,” said Su Muhereza, a Ugandan political commentator. “There was only so much one man like Bobi could do against the machine” of what she called “the security state.”
Mr. Museveni rose to power as the head of a revolutionary movement 35 years ago, promising to uphold democracy, safeguard the lives of Ugandans in a nation torn by coups and violence, and lamenting the corruption and greed that hindered African leaders from fulfilling their people’s aspirations.
At the time, he and his cadres “saw themselves as the essential leaders, not just of the country’s politics, but of a whole new national culture,” said Derek R. Peterson, a professor of history and African studies at University of Michigan.
But over time, Mr. Museveni and the governing National Resistance Movement tightened their grip on power by misusing public funds, employing patronage, using state institutions to persecute opposition leaders and deploying security forces to intimidate civil society groups and the media.
As his power became more entrenched, Mr. Museveni and those in his government became more and more convinced that they alone had “the right to author Uganda’s destiny,” Mr. Peterson said.
“Where once he was a youthful firebrand,” Mr. Peterson said, Mr. Museveni “now speaks as an elder, reminding his people about the virtues of the old culture, demanding deference, excoriating the decadence of the young.”
In the voting on Thursday, those youthful Ugandans were represented by Mr. Wine, a 38-year-old rapper-turned-lawmaker who mounted the biggest challenge yet to Mr. Museveni’s rule. Mr. Wine, whose real name is Robert Kyagulanyi, called on Mr. Museveni to resign and pointed to the corruption, chronic unemployment and poor public services across the East African nation.
The authorities responded by arresting Mr. Wine — including on the day he filed for his candidacy in November — and charged him with violating restrictions to control the coronavirus pandemic.
The arrest of Mr. Wine and other opposition figures set off nationwide protests that led to the deaths of at least 54 people as security forces dispersed demonstrators. As the campaign heated up late last year, Mr. Museveni accused the opposition of being backed by foreign “agents” and “homosexuals,” and said they wanted to start an “insurrection” that would sow chaos across the country.
Citing government abuses, Mr. Wine in early January filed a case with the International Criminal Court against Mr. Museveni and nine top security officials, accusing them of attempted murder and human rights violations.
On Saturday, Mr. Wine struck a defiant note, vowing to challenge the results in court and show the world that he was the rightful winner.
Local and foreign election observers questioned the validity and transparency of the vote after they were prevented from monitoring it for lack of accreditation. The United States mission in Uganda said that 75 percent of its accreditation requests had been denied, pushing it to cancel its observation of the vote.
A report seen by The New York Times, which had input from 2,000 observers with the Africa Elections Watch coalition deployed in 146 districts nationwide, documented late openings in most polling stations, incidents of illegally opened ballot boxes and the arrest of 26 members of civil society groups who were observing the election.
Mr. Wine said that between 50 and 60 military officers were still surrounding his seven-acre property and that they were blocking people from leaving or entering his home.
“The government is doing this to intimidate me, to make sure I don’t speak to the world,” he said, adding that he hoped that the international community would stand up for Ugandans. “I am glad the world is getting to see Museveni for who he is.”