Running the Democratic Republic of Congo is a tough and dangerous job. For decades, this African country the size of Western Europe has lurched between dictatorships, wars and vast humanitarian crises. Despite extraordinary natural resources, it remains desperately poor. Two leaders have been killed.

And yet, 19 candidates are in the race to become Congo’s next president in elections, the fourth in Congo’s history, that took place on Wednesday — and another 100,000 are running for seats in national, regional and local assemblies.

The vote is being closely watched not only by Congo’s nine neighbors, with whom it shares 6,500 miles of borders, but also by foreign powers. International interest in Congo has soared in recent years as countries try to stem climate change and transition to clean energy: Congo has the world’s second largest rainforest, as well as deep stores of the rare minerals needed to make electric cars and solar panels

After polling stations opened — or failed to open — creating long lines and scenes of disorder, the election took a rocky turn. In the capital, Kinshasa, where polling stations opened hours late, heated confrontations ensued between voters and officials. In several provincial towns, frustrated voters ransacked polling sites.

By midmorning, the largest poll monitoring body, run by the Roman Catholic Church, had reported violence at 8 percent of polling stations. By Wednesday evening, the national election commission announced that voting would continue on Thursday in areas where polling stations had failed to open at all.

The most famous presidential candidate is Denis Mukwege, a gynecologist who won the Nobel Peace Prize in 2018 for his work with sexual assault victims. But the firm favorite is the incumbent, President Felix Tshisekedi.

A voter poll published Tuesday by Ebuteli, a Congolese political research organization, and the Congo Research Group, based at New York University, gave Mr. Tshisekedi 49 percent support. His nearest rival, Moïse Katumbi, a business tycoon and one-time governor of the mineral-rich Katanga province, got 28 percent. Mr. Mukwege got less than 1 percent.

Populism and mud slinging dominated the monthlong campaign. Candidates stoked ethnic tensions with inflammatory language, or even threatened to declare war on neighboring countries. At least one person died in clashes between rival groups, Human Rights Watch said.

Yet many Congolese have been eager to vote. A frantic cacophony filled the broken streets of Kinshasa this week as rival campaigns made a last-minute push for votes. Music blared. Lines of motorbikes splashed through puddles. Bombast flowed, as did money.

“We are the victory before the victory,” declared Rovernick Kola, 29, a motorbike rider waiting to be paid $20 for driving in a convoy that waved posters of a parliamentary candidate.

Organizing an election in such a vast country would tax any bureaucracy — never mind in the world’s fifth-poorest country, with a population of about 100 million people, and some of Africa’s worst infrastructure.

To reach all of Congo’s 75,000 polling stations, the authorities sent Korean-made voting machines by boat on the Congo River, by plane across over 1,000 miles, and by foot into some of the world’s most impenetrable forests — a journey that can take three weeks, election observers say.

Ballots for 44 million registered voters were flown in from China, although the enduring conflict in eastern Congo meant at least 1.5 million people were not able to vote.

The entire effort cost $1.2 billion, the national election commission said.

Voting cards have been a major problem. In Congo’s hot, humid climate, the ink on many cards issued earlier this year has rubbed off in recent weeks. One survey of Kinshasa residents this week found that 73 percent of their cards were illegible — a recipe for chaos that played out at the polls on Wednesday.

Electoral observers worry that turmoil could facilitate cheating.

“The government created a system that allows numbers to be manipulated,” said the Rev. Rigobert Minani, the head of the biggest Catholic election group. “There’s a big potential for fraud.”

Official results are expected within 10 days, although are likely to come sooner, officials say.

When he came to power in 2019, promising to tackle corruption and empower the press, Mr. Tshisekedi offered at least the prospect of change in Congo. But his election was highly contentious.

Although results tallied by the Catholic Church showed that another candidate had won the December 2018 vote, Mr. Tshisekedi struck a power-sharing deal with the outgoing president, Joseph Kabila, that made him president.

The United States blessed that arrangement, which some saw as the best way to end Mr. Kabila’s 18 years of erratic, often harsh rule. But within a year it collapsed, and Mr. Tshisekedi, known to supporters by the diminutive “Fatshi,” set about consolidating his power.

Since then, critics say that his rule has grown increasingly repressive.

At Kinshasa main prison last Saturday, Stanis Bujakera, one of Congo’s best-known journalists, sat in the sweltering courtyard. Nearly 100 days earlier, the police had arrested him on charges of “spreading false information.” Now they were pressing him for his sources.

Mr. Bujakera, who is 33 and a U.S. resident, refused to talk. ”It’s not just me,” he said: Four other reporters have been threatened or assaulted by government officials or Tshisekedi supporters in the past month, the Committee to Protect Journalists said in a statement.

On the campaign trail, Mr. Tshisekedi whipped up anger against Rwanda, which he blames for the conflict in the east, and at a rally on Monday even threatened to declare war against Rwanda.

He sought to denigrate Mr. Katumbi, whose father was a Greek Jew, as an agent of foreign powers, and claimed that his opponent had paid Russian hackers to rig the election results.

Mr. Katumbi, for his part, slammed Mr. Tshisekedi for failing to deliver on promises to provide basic services to ordinary Congolese. And he criticized Mr. Tshisekedi for what he called his lavish lifestyle.

A gold tooth is the last remaining trace of Patrice Lumumba, Congo’s first prime minister, who was assassinated in 1961 after barely a year in office.

Belgium returned the tooth to Congo last year after it was retrieved from the home of a former colonial officer who had disposed of Mr. Lumumba’s body, but kept the tooth as a trophy. Now it sits in a coffin at a monument on a busy Kinshasa traffic junction.

Invoking Mr. Lumumba is an article of faith for Congolese politicians. To many, his fate embodies a tragic history shaped by meddlesome foreign powers that coveted Congo’s minerals or used the country as a geostrategic battleground.

In the 1960s, the C.I.A. plotted to kill Mr. Lumumba, believing he was a puppet of the Soviet Union. That presumption was false, Stuart A. Reid, author of “The Lumumba Plot,” said in an email. But there are striking similarities between that period and now.

“Now, as then, the central government is dysfunctional and cannot exert control over the country’s entire territory. Now, as then, U.N. peacekeepers have been sent in to provide security, and Congolese leaders wish to kick them out,” Mr. Reid said.

“And now, as then,” he added, “the framework of geopolitical rivalry guides Washington’s thinking” about Congo.

Since leaving office in 2019, Mr. Kabila, the former president, has kept a remarkably low profile — rarely appearing in public, and speaking out even less.

But in this election, speculation has grown that he is poised for a comeback. His party has called for a boycott of the vote, and he has been in regular touch with Mr. Katumbi, the main opposition challenger, Western officials said.

Several visitors to Mr. Kabila at his large ranch in the far south of Congo said he does little to hide his resentment of Mr. Tshisekedi, whom he accuses of betrayal.

That has given rise to concerns among Western officials and some Congolese that, should this election turn to chaos, Mr. Kabila could use his vast wealth — widely estimated to be in the billions — and his deep connections inside the security services to somehow exact payback.

Whether that will amount to anything is unclear. But it adds an extra element of volatility to an already-tense election.