An anticorruption crusader won a runoff election for Guatemala’s presidency on Sunday, handing a stunning rebuke to the conservative political establishment in Central America’s most populous nation.

Bernardo Arévalo, a polyglot sociologist from an upstart party made up largely of urban professionals, took 58 percent of the vote with 98 percent of votes counted on Sunday, the electoral authority said. His opponent, Sandra Torres, a former first lady, got 37 percent.

Alejandro Giammattei, the current president, who is prohibited by law from seeking re-election, congratulated Mr. Arévalo and extended an invitation to organize an “orderly” transition of power.

Full official results are expected within the coming days.

Mr. Arévalo’s win marks a watershed moment in Guatemala, both a leading source of migration to the United States and one of Washington’s longtime allies in the region. Until he squeaked into the runoff with a surprise showing in the first round in June, it was the barring by judicial leaders of several other candidates viewed as threats to the country’s ruling elites that was shaping the tumultuous campaigning.

Pushing back against such tactics, Mr. Arévalo made fighting graft the centerpiece of his campaign, focusing scrutiny on how Guatemala’s fragile democracy, repeatedly plagued with governments engulfed in scandal, has gone from pioneering anticorruption strategies to shutting down such efforts and forcing judges and prosecutors to flee the country.

Mr. Arévalo said on Sunday night that a priority of his government would be to put a stop to “political persecution against different types of government employees, and people focusing on corruption, human rights and the environment.”

One voter, Mauricio Armas, 47, said that he had cast a ballot for a candidate he believed in for the first time in decades. Mr. Arévalo and his party, Movimiento Semilla (Seed Movement), “seem like people who are not connected to criminal activity,” said Mr. Armas, a house painter and actor in the capital, Guatemala City.

Mr. Arévalo, 64, a moderate who criticizes leftist governments like that of Nicaragua, is nevertheless viewed in Guatemala’s conservative political landscape as the most progressive candidate to get this far since democracy was restored in the country in 1985 after more than three decades of military rule.

Drawing much of its support from voters in cities, Mr. Arévalo’s campaign stood in contrast to his rival’s, who focused largely on crime and vowed to emulate in Guatemala the crackdown on gangs by Nayib Bukele, El Salvador’s conservative president. Ms. Torres also highlighted social issues — opposing the legalization of abortion, gay marriage and marijuana — and supported increasing food assistance and cash payments to the poor.

“She promises security, doing the same as President Bukele in El Salvador,” said one supporter, Aracely Gatica, 40, who sells hammocks at a market in downtown Guatemala City.

This was just the latest unsuccessful bid by Ms. Torres, 67, the former wife of Álvaro Colom, who was Guatemala’s president from 2008 to 2012. In 2011, she divorced Mr. Colom in an effort to get around a law that prohibits a president’s relatives from running for office. (Mr. Colom died in January at 71.)

Although she was barred from running in that contest, she was the runner-up in the two most recent presidential elections. After the last one, in 2019, she was detained on charges of illicit campaign financing and spent time under house arrest. But a judge closed the case late last year, opening the way for her to run.

Despite some obvious differences, Mr. Arévalo and Ms. Torres raised some issues in common. Both candidates, for instance, called attention to Guatemala’s dearth of decent infrastructure. Outside Guatemala City, the country is lacking in paved roads, and Mr. Arévalo and Ms. Torres proposed building thousands of miles of new roads and improving existing ones. Both also vowed to build Guatemala City’s first subway line.

Still, Mr. Arévalo symbolizes a break with the established ways of doing politics in Guatemala. The race unfolded amid a crackdown by the current conservative administration on anticorruption prosecutors and judges, as well as nonprofits and journalists like José Rubén Zamora, the publisher of a leading newspaper, who was sentenced in June to up to six years in prison.

While Guatemala’s president, the broadly unpopular Mr. Giammattei, cannot seek re-election, concerns over a slide toward authoritarianism have grown more acute as he has expanded his sway over the country’s institutions.

This institutional fragility was on display on Sunday. Blanca Alfaro, a judge who helps lead the authority that oversees Guatemala’s elections, said she planned to resign in the coming days because of what she said were threats against her. Gabriel Aguilera, another judge on the electoral authority, said he had also received threats.

In Guatemala City, firefighters said they had responded to a fire caused by a small homemade bomb at a voting center in a middle-class area. While no one was killed and the blaze was quickly extinguished, they said that they aided people showing signs of emotional stress. It was not immediately clear who was behind the bombing.

Before Mr. Arévalo’s showing in the first round, a victory by an establishment standard-bearer seemed almost certain. But rather than benefiting the establishment’s preferred candidates, the disqualification of several contenders opened a path for Mr. Arévalo.

After he made it into the runoff, a top prosecutor the United States has placed on a list of corrupt officials tried to prevent Mr. Arévalo from running, but that move also backfired, prompting calls from Guatemalan political figures across the ideological spectrum to allow him to remain in the race.

Mr. Arévalo, an intellectual, is the son of a Juan José Arévalo, a former president who is still exalted for creating Guatemala’s social security system and protecting free speech. After his father was forced into exile in the 1950s, Mr. Arévalo was born in Uruguay and grew up in Venezuela, Chile and Mexico before returning to Guatemala as a teenager. He was serving as a member of Congress when his party tapped him this year as their candidate.

In recent days, the prosecutor who tried to bar Mr. Arévalo from the race, Rafael Curruchiche, resurrected his attempt to suspend Mr. Arévalo’s party. Citing what he claimed were irregularities in the process of gathering signatures for creating the party, Mr. Curruchiche said that he could suspend the party after Sunday’s election and issue arrest warrants for some of its members.

Such a move might quickly weaken Mr. Arévalo’s ability to govern. Another warning sign was the high level of abstention in the runoff, with 45 percent of the electorate casting votes.

But Ricardo Barrientos, a member of an alliance of groups that oversaw the electoral process, said both the abstention rate and Mr. Arévalo’s wide margin of victory were expected, and in line with polling. “This is an overwhelming majority” for Mr. Arévalo, Mr. Barrientos said.

Mr. Arévalo has vowed to alleviate poverty in Guatemala, one of Latin America’s most unequal countries, through a large job creation program aimed at upgrading roads and other infrastructure. He has also promised to ramp up agricultural production by providing low-interest loans to farmers.

Mr. Arévalo has framed such proposals as ways to keep Guatemalans from leaving for the United States, where they figure among the country’s largest migrant groups. Various factors fuel the migration, including low economic opportunity, extortion, corruption among public officials and crime.

Mr. Arévalo made tackling corruption and impunity the nucleus of his campaign. He distanced himself from rivals seeking to mirror Mr. Bukele’s gang crackdown in neighboring El Salvador, saying that Guatemala’s security challenges are different in size and scope, with gang activity concentrated in certain parts of the country. Mr. Arévalo is proposing to hire thousands of new police officers and upgrade security at prisons.

William López, 34, a teacher in Guatemala City who works at a call center, said he viewed Mr. Arévalo and his party, Semilla, as “an opportunity for profound change, since they’ve shown they don’t have skeletons in their closet.”