Colombian presidential candidate Ivan Duque, for the Democratic Center party, after voting at a polling station in Bogota during the first round of the presidential election in Colombia. (Luis Acosta/AFP/Getty Images)

A right-wing lawyer and a leftist ex-mayor claimed first and second places in Colombia’s first-round presidential elections Sunday.

A June 17 runoff will determine the next president to guide Latin America’s third-most-populous nation through a troubled moment marked by soaring cocaine production, a shaky peace accord with a Marxist rebel group and the influx of Venezuelan migrants flooding over the border to escape an economic crisis next door.

With 98 percent of the votes counted, conservative 41-year-old Iván Duque nailed down 39 percent of the vote, according to Colombia’s national electoral agency. He was followed by the progressive 58-year-old economist and ex-mayor of Bogota, Gustavo Petro, with 25 percent.

A mathematician who was the centrist mayor of Medellin, Sergio Fajardo, received 24 percent of the vote. Outgoing president Juan Manuel Santos’s former vice president, Germán Vargas Lleras, garnered 7 percent, and Santos’s peace negotiator, Humberto de la Calle, finished with 2 percent.

The runoff will be historic. Colombians haven’t forgotten that an assassin shot the populist leftist presidential candidate Jorge Eliécer Gaitán in 1948. Since then, outwardly left-wing candidates have been scarce in a country that gained a reputation throughout the 20th century for leaning further right than its neighbors. The outcome Sunday gives Colombians a clear choice in ideology, one they haven’t had for decades.

Colombia is polarized. A 2016 peace accord led to the demobilization of thousands of fighters from the FARC rebel group last year, but while some Colombians want to forgive and move on, others are frustrated, insisting on harsher punishment for FARC leaders than is pending.

And a wave of poor Venezuelan migrants crossing illegally into Colombia is challenging an underemployed workforce.

In the post-conflict era, the longtime American ally’s security issues are changing. Colombia’s next president will have to deal with a major increase in the amount of land under coca cultivation. After two decades and a U.S. package of more than $10 billion in aid to fight against drug-trafficking groups, a few violent, criminal organizations have arisen with the end of the fighting. Peace talks with the ELN, a smaller rebel group, appear fragile.

“If Petro were to win, it could create big problems for Colombia’s relations with the United States, least because I would think [President] Trump’s immediate reaction to Petro would be very negative,” said Philip Paterson, a Latin American analyst at Oxford Analytica. “We might see a lot more frustration between Washington and Bogotá in terms of Washington pushing for coca crop eradication programs — which I think Petro would be far less likely to follow through on, where Duque would do it enthusiastically.”

The issues on voters’ minds reflect a Colombia that more and more resembles its South American neighbors, where ire toward corruption, frustration over access to effective health care, and attention to environmental issues are competing with Colombia’s age-old political debates of how to tackle drug trafficking and stop armed conflict.

For voters, Duque represents a nostalgic return to the hard-line security stance of former president Álvaro Uribe. Duque has called for harsher punishments for FARC leaders, who face restricted liberties if jurors find they tell the truth in a special tribunal.

He was elected in 2014 as a senator in Uribe’s Centro Democratico party. Before that, he worked at the Inter-American Development Bank in Washington.

Duque says Colombia’s economy is hamstrung by regulations and taxes on private enterprise. He is calling for tax cuts and reductions in public spending.

Alexandra de Brigard, a ­47-year-old architect, said she supports Duque with the hope that he will restore Colombia to what it was before outgoing President Juan Manuel Santos took office in 2010.

“I’m from the generation that lived a really horrible and violent chapter of Colombia’s history. Uribe saved us when it seemed like we had no hope,” she said.

“Santos did the exact opposite of what he promised, the exact opposite of Uribe,” she added, reflecting many pro-Duque voters’ regret and frustration that the second-term Santos broke the continuity of Uribe’s hard-line security policy with FARC.

Victor Manuel Sierra, also 47, says he is voting for Duque because his 25-employee cable wire business is suffocating under the weight of high taxes.

Detractors say behind Duque’s moderate rhetoric are staunch, ultraconservative sectors backed by regional business elites.

“Duque represents a defense of the status quo,” said Alvaro Villarraga of the Democratic Culture Foundation.

Petro is a former member of a left-wing armed movement known as ­M-19. He worked for its political wing until it disarmed in 1991 as part of a peace process.

Elected to the Senate, Petro gained a reputation for exposing corruption. In 2011, he was elected mayor of Bogotá.

Petro wants to dismantle Colombia’s mining and oil sector and replace it with renewables, as well as strengthen the agricultural sector — where many of the rural poor are employed.

Petro has said he would buy land if landowners won’t pay his proposed higher taxes on underused property. His opponents cry expropriation and equate him with Hugo Chávez of Venezuela.

“He’s talked about wanting to wind down coal and oil in three years, which I think is extremely ambitious and unlikely to happen in reality,” Paterson says. “I certainly don’t think he would be hostile to business. He’d still be trying to encourage international private investment into Colombia.”

“This idea that he’s the ‘New Chávez’ is way off the mark.”

His supporters see the upside to a leader with leftist sympathies who presents himself as an outsider. “I like Petro for his ideas: his defense of the environment, and offering free higher education,” says 34-year-old political scientist Andrés Ignacio Sánchez, who is unemployed.

“Forever now he’s gone against institutions and the way they currently work.”