SAN SALVADOR, El Salvador — A youthful former mayor of the capital easily won El Salvador’s presidency, getting more votes than his three rivals combined to usher out the two parties that dominated politics for a quarter century in the crime-plagued Central America nation.

The Supreme Electoral Court declared Nayib Bukele the winner late Sunday, saying he had nearly 54 percent of the votes, with about 90 percent of ballots counted. Carlos Callejas of the Nationalist Republican Alliance ended in a distant second at less than 32 percent, while even farther back were former Foreign Minister Hugo Martinez of the currently governing Farabundo Marti National Liberation Front and a minor party candidate.

By surpassing the 50 percent threshold, Bukele won outright and avoided the need for a March runoff against the No. 2 finisher.

Bukele claimed victory even before the formal announcement of his win, inviting a jubilant crowd in the capital of San Salvador to celebrate in the streets.

“This is a victory for the Salvadoran public, really,” Bukele said to cheers.

All four candidates promised to end corruption, stamp out gang violence and create more jobs, with crushing crime at the top of the agenda, but Bukele’s campaign resonated more with his countrymen and polls had pointed to him as the strong front-runner going into the election. Roughly 67,000 Salvadorans belong to gangs that terrorize their communities with extortion, murder and other forms of violence.

The candidates proposed creating economic opportunities and restoring social values to dissuade Salvadorans from engaging in criminal behavior.

El Salvador is small both in size and population, with just 6.5 million people. Close to a third of its households live in poverty, while the World Bank says per capita income is $3,560. Salvadorans searching for a better life have joined recent caravans of migrants trekking across Mexico hoping to reach the U.S.

Bukele, 37, made his political debut in 2012 as a small-town mayor with the FMLN and won election in the capital three years later, automatically making him a potential presidential contender. But his frequent criticism of the leftist party’s leadership got him expelled, and he ran for the presidency as the unlikely standard-bearer for the small, conservative Grand Alliance for National Unity, whose initials — GANA — mean “win” in Spanish.

The FMLN and the conservative Nationalist Republican Alliance, known as ARENA, had dominated El Salvador’s politics since a 1992 peace deal ended a vicious civil war. But both parties have been stained by corruption scandals and neither has been able to stem gang violence.

“I came to vote because I want the country to change, because we are tired of so much corruption,” said one voter, Estela Henriquez, at a polling place in the capital.

More than 4,500 election observers, including representatives of the Organization of American States and the European Union, were on hand. There were no reports of major problems in voting.