SAN SALVADOR — A former mayor of San Salvador was declared the winner Sunday night in El Salvador’s presidential race, saying the country had left behind the postwar period by electing a young alternative to the two-party ­system.

Nayib Bukele, 37, who campaigned as a change from the country’s traditional politics, dominated by former guerrillas and a party associated with past military-backed governments, had 53.7 percent of the vote with 89 percent of the ballots counted.

“In this moment, we can say with full assurance that we have won the presidency in the first round,” Bukele told a crowd of supporters just after 9 p.m.

He added: “El Salvador has turned the page on the postwar era. And now we can start to look toward the future.”

One of voters’ most significant concerns is  violence blamed on gangs, which have enormous power in this Central American nation. Although homicide rates have been decreasing from a peak in 2015, El Salvador remains one of the most violent countries in the world, with more than 3,300 killings last year in a nation of about 6.5 million residents. The violence is a key factor driving migration to the United States. The presidential candidates pledged to find ways to reduce the violence, offering crime-prevention programs instead of an iron-fisted approach. But they provided few details.

Bukele, a businessman, ran for the center-right party GANA, which stands for Grand Alliance for National Unity. The right-wing Nationalist Republican Alliance, known as ARENA, finished first in legislative elections last year, but its candidate, supermarket mogul Carlos Calleja, was running second on Sunday night, with 31.6 percent. Hugo Martínez, a former foreign minister and a member of the left-wing Farabundo Marti National Liberation Front, or FMLN, had 13.9 percent of the vote. A candidate needs more than 50 percent to avoid a second round. President Salvador Sánchez Cerén of the FMLN is limited to one term. 

Since the end of El Salvador’s 12-year civil war in 1992, two parties have dominated the country’s political system: ARENA and the FMLN. But Salvadorans were looking for a new option after major corruption scandals and what many voters see as a lack of progress in tackling crime.

“The violence here is out of control,” said Gerardo Alfaro Gomez Castillo, 37, a security guard. “Only Bukele’s security plan is appealing to me because it’s something different than the measures we’ve seen in the last 15 years.”

The run-up to the election was marked by violence, with 285 people killed in January, including eight police officers. That was fewer homicides than in January 2018, but the targeting of police was seen as a sign that gangs might be pressuring candidates to negotiate with them once they were elected.

The police killings “made us remember the gangs continue to have a political presence and a destabilizing presence in the country,” said Veronica Reyna, a security expert with the human rights organization Passionist Social Service, affiliated with the Catholic Church.

In 2003, under President Francisco Flores of ARENA, El Salvador began to implement “mano dura” or strong-hand policies against the gangs. When the FMLN won the presidency in 2009, it promised it would handle security differently, addressing the root causes of violence with programs focusing on youth and economic development.

In 2012, President Mauricio Funes of the FMLN initiated negotiations with the gangs to reach a truce, offering them concessions such as less restrictive prison conditions. Murder rates plummeted but then skyrocketed again when the talks fell apart in 2014.

The truce made it clear that gangs are important political forces in El Salvador. An investigation by media outlet El Faro revealed that then-candidate Bukele paid gangs to vote in the 2015 mayoral elections. El Faro reported that both ARENA and FMLN paid gangs to cast ballots in the 2014 presidential election. 

Bukele denied directly negotiating with gangs but has recognized the importance of earning gang approval to carry out government projects. The vice president of ARENA recently acknowledged in an interview that “there are places where we have to pay to enter.” The FMLN has denied the allegations.

The office of the attorney general has an ongoing investigation into pacts that politicians have made with gang members to affect voter turnout.

“The ultimate actor who determines whether you have more or less homicides tomorrow or right now or in a week is not the government. It’s the gangs,” said José Miguel Cruz, an expert on Salvadoran gangs at Florida International University. “They do it for political purposes as a bargaining tool to improve their position vis-a-vis the government or vis-a-vis the society.”

Politicians have tried to distance themselves from any type of dialogue with the gangs because of the public backlash that occurred after the last talks.

Under the FMLN’s second presidential term, from 2014 to 2019, the party further embraced the mano dura measures it had criticized. Security forces began to commit an increasing number of extrajudicial killings, according to human rights groups and U.N. officials. The government has denied that allegation, saying that most of the dead perished in shootouts with security forces.

Neither of the past approaches has satisfied Salvadorans affected by violence on a daily basis.

“They’ve failed us,” said Jose Isaac Cubias Hernandez, 20, an engineering student who had debated backing Bukele or not voting at all as the election neared. “Mano dura didn’t work. The truce didn’t work.”

During the campaign, all three major candidates said they favored violence prevention, through providing sports and art activities for young people, as well as through job training programs.

“Candidates always portray themselves as doing things differently depending on what has been the prevailing security program of the last government,” Cruz said. “In the end, they end up doing almost the same thing: new versions of the mano dura or zero-tolerance policies.”

Bukele has said he will not enact mano dura policies, but many prominent members of his party have been leading proponents of those tactics. Calleja’s party, ARENA, has embraced the iron-fisted approach for years. Martínez has spoken against the policy, but he was part of the FMLN government that enacted it.

The incoming administration will inherit a police force accused of corruption and extrajudicial killings, and a troubled jail system. El Salvador has the world’s second-highest incarceration rate after the United States — but many members are able to continue communicating with gangs while in prison.

Analysts say the new government needs a sophisticated strategy.

“A security plan is not soccer fields and soccer balls and employment,” Reyna said. “It’s about defining how the police will act, defining how to approach gang-controlled areas, how to address the penitentiary system, and what type of dialogue with these criminal structures they will be able to have.”

Mary Beth Sheridan in Mexico City contributed to this report.