Alejandro Giammattei will succeed corruption-tainted outgoing President Jimmy Morales, who leaves office in January.
Conservative Alejandro Giammattei was elected as Guatemala's president on Sunday, defeating former first lady Sandra Torres in a run-off, the central American country's electoral court said.
With the results being updated in real time on the court's website, the institution's president Julio Solorzano declared the result "already irreversible."
Giammattei will succeed corruption-tainted outgoing President Jimmy Morales, who leaves office in January.
"The aim is fulfilled," Giammattei had said earlier.
He had polled almost 58.5 percent with a lead of 550,000 vote s and only a few thousand left to count when the court declared him the victor.
Giammattei will be under immense pressure from the United States to implement a controversial migration pact that would allow Washington to send most Honduran and Salvadoran asylum seekers who passed through Guatemala back to the poor, crime-stricken country.
The two candidates had both avoided committing to strong positions on the US deal.
Corruption was the main issue leading up to the first round of elections in June – which Torres topped – but that has been superseded by the political scandal over the migration deal.
Neither candidate arrived with a glowing reputation.
The center-left Torres, whose ex-husband Alvaro Colom was president from 2008-2012, has been suspected of involvement in corruption.
Influential businessman Dionisio Gutierrez recently described her as "a questionable politician with a history that should worry any citizen."
Giammattei has hardly come off any better.
Investigative website Nomada branded him as "impulsive... despotic, tyrannical... capricious, vindictive," a mong other undesirable traits.
But the 63-year-old, a doctor by profession, scored well on voter concerns such as the economy, corruption and security, according to Risa Grais-Targow of the Eurasia Group.
However, he now faces "a lose-lose scenario" regarding the migration pact, Grais-Targow said.
One of Morales's last acts as president was to authorize an agreement with the US administration of Donald Trump designating Guatemala as a "safe third country," which would permit Washington to turn away asylum seekers who didn't seek refuge when passing through Guatemala.
The pact -- part of Trump's campaign to stem the flow of migrants to the southern US border -- has proved highly unpopular in Guatemala, with demonstrators blocking roads and occupying the University of San Carlos in protest.
In a poll by Prodatos for the Prensa Libre newspaper, 82 percent of respondents opposed it.
'Risk of retaliation'
But rejecting the migration pact would run the "risk of retaliation from Trump," Grais-Targow said, after the US leader threatened a travel ban, tariffs and remittance fees if the country didn't bend to his will .
Remittances from Guatemalans in the US are a crucial part of the economy, reaching a record $9.3 billion last year. That compares to Guatemala's export revenue of $10.5 billion.
According to the World Bank, remittances account for 12 percent of the country's GDP.
The agreement was reached last month despite Guatemala's constitutional court having earlier granted an injunction blocking Morales from signing the deal.
Almost 60 percent of Guatemala's 17.7 million citizens live in poverty, and the country has one of the highest murder rates in the world.
Around half the killings are blamed on drug trafficking and extortion operations carried out by powerful gangs.
Morales, barred by Guatemalan law from seeking a second term, urged his replacement to reduce undocumented migration, improve education and tackle chronic malnutrition in the under-fives, which affects 46 percent of infants.
Guatemalans aren't subject to Trump's proposed migrant measures, but given that poverty in some indigenous areas reaches 80 percent, many embark on the journey in search of the "American dream" despite the dangers.
Since December, at least five Guatemalan children have died in US custody after crossing into the country from Mexico.
And in June, a woman and three children died from heat and dehydration in Texas.
"The problem is that as there's no work in Guatemala, many people want to migrate and it's sad what's happening to our Guatemalan brothers who die or are killed," Emilio Canel, a 26-year-old farmer in Sumpango, told AFP.
More than 250,000 Guatemalans were detained between October 2018 and July this year for trying to enter the US illegally, Washington's embassy said.