For generations, the conflict was the center of presidential politics. Yet how the peace deal signed by Mr. Santos was to be put into effect was not often discussed in the campaign, and sometimes appeared to be an afterthought.

Instead, Colombia moved toward a new set of questions: How should the country tackle the corruption scandals that have hit it, along with other countries in the region? What should be done about the rising number of Venezuelan refugees who have poured over the country’s borders? What is to be done about rising coca production?

But the war carries a long shadow, and the peace deal affected the fortunes of both men on the presidential ballot.

Mr. Duque was aided by his party’s long opposition to the peace deal; it argued that it was too lenient on drug traffickers. Many who voted the deal down after a referendum in 2016 gave their votes to Mr. Duque.

The end of the war with the FARC appeared to help Mr. Petro, too, as the first serious left-wing candidate for president in years. Some analysts said peace may have softened the stance of many Colombians against ex-rebels, allowing a former guerrilla to make headway.

The campaign may offer some hints as to how Mr. Duque will govern.

He published a book called “The Future Is at the Political Center” this year and backed off some of his party’s more right-wing stances. And while he has expressed doubts about the peace deal agreed to in 2016, he has not asked to overturn it. He has, though, suggested some modifications.