GUATEMALA CITY — Guatemalans on Sunday elected Alejandro Giammattei as their next president. When he takes office Jan. 14, he will inherit a nation plagued by years of political scandal, where a recent surge in migration has laid bare the monumenta l challenges ahead.

Giammattei, the right-wing Vamos party candidate who is a former prisons director, beat out former first lady Sandra Torres for the next four-year term. The presidential runoff election came at a crucial moment — as Guatemala prepares for the possible implementation of a “safe third country” agreement with the United States, a plan touted by the Trump administration but with potentially grave consequences for a country whose own citizens are fleeing in droves.

Guatemala is the leading country of origin of migrants and asylum seekers apprehended at the U.S. southern border.

During his campaign, Giammattei outlined his plan to keep people from wanting to leave, pledging to build an “economic wall” through job creation. The country’s significant inequality and the abject poverty in rural areas have gone mostly unaddressed since Guatemala’s civil war, which ended in 1996. The current exodus reflects the loss of hope for many of Guatemala’s poorest.

Guatemala's new president wants to change a migration deal the Central American country signed with the Trump administration last month. (Reuters)

“We will focus on the construction of a different Guatemala,” Giammattei said when he proclaimed himself president-elect while results were still coming in.

With more than 99 percent of votes counted, he held nearly a 16-point lead. Turnout was dismal. Only 42 percent of the country’s 8.15 million registered voters participated, far less than the 56 percent in the 2015 presidential runoff election.

In the lead-up to this year’s general election, two of the top three contenders were barred from running mid-campaign, and another candidate was arrested in the United States on drug trafficking and weapons charges. Legal battles to bar candidates, especially former attorney general and anti-corruption crusader Thelma Aldana, were widely considered politically motivated.

No candidate in a field of 19 obtained 50 percent of the vote in June, prompting the runoff between centrist National Unity of Hope party candidate Torres, who had come in first, and Giammattei, who had placed second.

The subsequent campaign was uninspiring, according to José Carlos Sanabria, a political analyst at the Association for Research and Social Studies.

“Broadly speaking, in many regards, the campaign was characterized by its weakness. It was a campaign without much depth in terms of proposals or an in-depth discussion of plans for government,” Sanabria said.

“The apathy, disinterest and disenchantment of many citizens toward the candidates and parties is quite high,” he said.

Outgoing President Jimmy Morales came into office in the wake of mass protests against corruption and the resignation and arrest of his predecessor, Otto Pérez Molina. But hopes generated by his anti-corruption platform would lead to disappointment. After a United Nations-backed commission began investigating Morales for illegal campaign financing, he moved to shut down the commission, whose mandate expires next month.

Concerns about impunity within the next administration linger. Giammattei was prosecuted for extrajudicial executions after police killed seven inmates when he was director of Guatemala’s prison system. The case continues to cast a long shadow despite his acquittal.

Torres and her party have been accused of corruption and mismanagement. She has denied those accusations, but is likely to face prosecution as soon as the election process is formally over and she loses her immunity from prosecution as a candidate.

Misrael Cardenas, 59, said he did not vote. He sells rat poison, used shoes and assorted knickknacks on a street corner in Guatemala City.

“We have to work,” he said. “If we don’t work, we don’t eat.”

Cardenas said he hopes the next president will set the country straight. Unemployment, poverty and violence are huge problems, he said.

Poverty and violence are the main reasons Guatemalans identify as reasons for fleeing the country.

Instead of helping to address the root causes of the exodus, the U.S. government is pushing its policies of crackdowns and restrictions on asylum seekers onto Mexico, Guatemala and beyond, said Mike Allison, a political science professor at the University of Scranton in Pennsylvania.

“U.S. policy toward Guatemala is shortsighted,” he said. “The current administration is looking for immediate gratification at no financial cost.”

Last month, Morales’s government signed an immigration deal with the Department of Homeland Security that would force Hondurans, Salvadorans and others transiting Guatemala to seek asylum there instead of in the United States.

The agreement was met with protests and widespread condemnation in Guatemala, as well as criticism from U.S. Democrats and migrant rights groups.

Giammattei criticized the circumstances of the negotiations by an outgoing government, and Torres rejected the notion that Guatemala is a safe country. Once in office, the next president would have the power to overturn the agreement, but neither candidate has promised to do so.

The deal remains in limbo. Guatemala’s highest court issued a provisional injunction against its implementation, determining that it requires congressional approval. Court proceedings are ongoing.