SAN SALVADOR – Salvadorans elected Nayib Bukele, the media-savvy forms mayor of the capital, as their next president on Sunday, delivering a sharp rebuke to the two parties that emerged from the country's brutal civil war in the 1980s and having success power ever since
The dramatic win for Mr. Bukele, 37, who was running as an outsider, under-represented the country's traditional parties. Voters appeared to be willing to gamble on a relative newcomer to the country's poverty and violence, shutting out the right- and left-wing parties that have dominated Salvadoran politics for three decades.
"Today we have turned the page on the postwar period," Mr. Bukele said, appearing in blue jeans and his trademark leather jacket to declare victory.
Attacks from both the left and the right seemed to have little effect on Mr. Bukele's popularity, which was driven by a social media campaign portraying him as a reformer willing to take on the ossified political establishment.
The conservative Nationalist Republican Alliance, known as Arena, was founded in 1981 by the extreme-right leader Roberto D 'Aubuisson, who was accused of organizing death squads during the civil war. During its two decades in government, it is itself a business-friendly party, although it has never disowned its founder.
The F.M.L.N. was the party of the leftist guerrillas who put down their arms after peace accords were signed in 1992 and won the presidency in 2009. Although poverty rates have fallen somewhat during the past decade, two successive F.M.L.N. governments have struggled to deal with soaring street gang violence.
Mr. Bukele said, after 30 years, Roberto Cañas, a political scientist at José Simeón Cañas Central American University, said, "It's not his program, nor his speeches," Mr. Cañas said. "It is because they are tired, angry, fed up with corruption, sick of broken promises – and what they see in him is that he does not represent all that."
Analysts said the three main candidates' proposals differed little, but Mr. Bukele was able to set himself apart on the issue of corruption, which has roiled politics across Latin America and paved the way for candidates promising to combat it.
In El Salvador, both traditional parties made for easy targets. President Tony Saca, an Arena politician, is serving a 10-year prison sentence after plotting guilty last year for charges of embezzlement and money laundering in more than $ 300 million in public funds.
Mauricio Funes, a former television broadcaster who was the FMLN's first president is accused of embezzling $ 351 million. In 2016, he fled to Nicaragua, which has granted him asylum.
"In the popular imagination, the left was decent even though it was not a good administrator," said Salvador Samayoa, a former F.M.L.N. leader who is now an independent consultant. The Funes case, he said, led to the perception that the party was neither.
Mr. Bukele made attacks on corruption in the centerpiece of his campaign, running on the slogans "Give us back what was stolen" and "There is enough money when nobody steals it."
He has proposed that El Salvador adopt a version of the international anticorruption commission that has been active in neighboring Guatemala for more than a decade, although he has offered few details.
Mr. Bukele’s outsider status is relatively new. He was mayor of San Salvador for the F.M.L.N. until he was expelled from the party in 2017 about his outspoken criticism of it. Looking for a vehicle for his campaign, he joined forces with a small right-wing party, the Grand Alliance for National Unity, known as Ghana.
He has been carefully cultivating his social media presence since the beginning of his political career six years ago, said Amparo Marroquín, a professor of communication and culture at the Central American University.
The videos on Mr. Bukele's Facebook page alternate between packaged clips showing him speaking before large crowds and awkward appeals from his living room, where he sits on an off-white sofa in front of a giant abstract painting.
He spent little time traveling the country, did not turn up for candidate debates and avoided interviews with journalists who might challenge him, leading critics to suggest that he was intolerant.
"There is a perception of a person who is arrogant, authoritarian, who doesn't expose himself to dialogue , "Said Alvaro Artiga, a political science professor at the Central American University.
As mayor of San Salvador, Mr. Bukele helped redevelop the historic center, sponsor a children's orchestra and build a library, all popular projects among voters. But he has been taking projects that might have been a political cost, such as controlling the city's short traffic or introducing a recycling program, Ms. Marroquín said.
As a candidate, he proposed grand infrastructure projects, including a train along the Pacific Coast and a new airport, without explaining how they would be paid for. Calleja, 42, his Arena opponent, is an executive in his family-owned supermarket chain, though he has never held an elective office. He promised to create 300,000 jobs, although he was vague as to how he would pay for his proposals.
All of the candidates said they wanted to maintain good relations with the United States, despite friction about El Salvador's severing of Taiwan's diplomatic services in favor of China and the Trump administration are endowed with a program that allows 250,000 Salvadorans to live legally in the United States.
Beyond issues of corruption and the economy, security concerns dominated the race. Homicide rates have declined from their peak in 2015, but El Salvador remains one of the most violent countries in the world outside war zones. The candidates said they would emphasize prevention programs in contrast to the current government's tactics, which have focused more on cracking down on street gangs.
Analysts say those proposals indicate that they have become political forces, able to command votes and use violence for political gain. The two main parties, as well as Mr. Bukele, having negotiated with the gangs
Voters want to hear candidates take a tough stand against the gangs, which are considered the "mother of all evils," Ms. Marroquín said. But the candidates "have realized that they are an actor that can define an election."