Conservative Alejandro Giammattei swept aside his centre-left rival in Guatemala's presidential election on Sunday, and now inherits an unpopular migration deal agreed under duress with the Trump administration that could severely test his country.

With preliminary results from over 99 per cent of polling stations counted, the electoral tribunal declared Giammattei the winner with more than 58 per cent of the vote, ahead of his centre-left rival, Sandra Torres, with 42 per cent. Torres is the former wife of Alvaro Colom, who served as president from 2008-2012.

Giammattei, a trained surgeon and veteran public sector bureaucrat who had failed in three previous bids to secure the presidency.

Speaking a few hours before being declared the winner, Giammattei said he wanted to see what could be done to improve the deal that outgoing President Jimmy Morales made to stem U.S.-bound migration from Central America.

Giammattei will not take office until January, by which time Guatemala may be under severe pressure from the deal, which effectively turns the country into a buffer zone, by forcing migrants to seek refuge there rather than in the United States.

"I hope that during this transition the doors will open to get more information so we can see what, from a diplomatic point of view, we can do to remove from this deal the things that are not right for us, or how we can come to an agreement with the United States," Giammattei, 63, told Reuters in an interview.

'It's not right for the country'

Threatened with economic sanctions if he said no, Morales reached an accord in late July to make Guatemala — despite endemic poverty and violence that have led hundreds of thousands of its people to migrate north — viewed as a safe third country for migrants.

"It's not right for the country," Giammattei said of the deal. "If we don't have the capacity to look after our own people, imagine what it will be like for foreigners."

Asked about Giammattei's comments, U.S. border patrol chief Carla Provost said in an interview with Fox News channel, "It certainly is a concern. We need both Mexico and Guatemala to continue doing what they're doing," referring to Mexico's own campaign to block migrants from crossing its border with the United States.

It is unclear how much Giammattei will be able to do to change the deal, which would require Hondurans and Salvadorans to apply for asylum in Guatemala rather than the United States. It also foresees granting U.S. visas to some Guatemalan workers.

Risa Grais-Targow, Latin America director at consultancy Eurasia Group, said while the accord struck with Trump risks a popular backlash, not honouring it could expose Guatemala to U.S. taxes on remittances or tariffs on its goods.

"The next president faces a lose-lose situation when it comes to managing the deal with the United States," she said. "That is the biggest challenge the incoming president faces."

Supporters of Giammattei celebrate at his campaign headquarters in Guatemala City. (Jose Cabezas/Reuters)

Giammattei will also take on a country struggling with a 60 per cent poverty rate, plus widespread crime and unemployment, which have led hundreds of thousands of people to migrate north.

He has promised to erect an "investment wall" on the border between Guatemala and Mexico to curb migration, and also proposed bringing back the death penalty.

Corruption body wrangling

Many Guatemalans are fed up with the political class after investigations by the International Commission against Impunity in Guatemala (CICIG), a United Nations-backed anti-corruption body, led to the arrest of then-President Otto Perez in 2015, then threatened to unseat his successor Morales, a former TV comedian.

Morales narrowly escaped impeachment, and the CICIG also went after Torres for suspected campaign finance irregularities. As a candidate, she was immune from prosecution.

Both candidates vowed to fight corruption – albeit without "foreign interference," an apparent nod to the CICIG.

Giammattei pledged to run an honest government as he voted.

"We'll battle corruption from the very first day," he said.

Morales, who ordered the termination of the CICIG's mandate as of September, was barred by the constitution from standing again.