BOGOTA - Colombians rejected a peace deal with leftist rebels by a razor-thin margin in a national referendum Sunday, scuttling years of painstaking negotiations and delivering a stunning setback to President Juan Manuel Santos, who vowed to keep a ceasefire in place and forge ahead with his efforts to end a half-century of war.

Final results showed that 50.2 per cent opposed the accord with the Revolutionary Armed Forces of Colombia while 49.8 per cent favoured it - a difference of less than 54,000 votes out of a total of 13 million. Pre-election polls had predicted the “yes” vote would win by an almost two-to-one margin.

“I won't give up. I'll continue search for peace until the last moment of my mandate,” Santos said in a televised address appealing for calm and in which he tried to reassure voters he was in control of the situation.

To save the accord, Santos ordered his negotiators to return to Cuba on Monday to consult with FARC leaders who watched the results come in from the communist island. He also promised to listen to opponents in a bid to strengthen the deal, which he said is Colombia's best chance for ending a conflict that has killed 220,000 people and driven almost 8 million people from their homes.

“I've always believed in a wise Chinese proverb to look for opportunities in any situation. And here we have an opportunity that's opening up, with the new political reality that has demonstrated itself in the referendum,” he said before descending to the steps of the presidential palace to address a small group of supporters, some of them crying and waving white flags symbolizing peace.

The shock outcome, comparable to Britain's decision to leave the European Union in the Brexit vote, opens an uncertain outlook for an agreement that was signed less than a week ago by Santos and the FARC in a ceremony attended by heads of state, U.N. Secretary-General Ban Ki-moon and U.S. Secretary of State John Kerry - all of whom heralded the accord.

Opposition to the accord, led by influential former President Alvaro Uribe, argued that the government was appeasing the FARC and setting a bad example that criminal gangs would seize on by sparing rebels jail time if they confess their crimes and guaranteeing the group 10 seats in congress through 2026. If the “no” vote prevailed, Uribe said, the government should return to the negotiating table.

But that is an option Santos has previously ruled out.

With the government's ability to govern now in question all eyes are on Uribe, the country's most-popular politician and whose almost decade-long military offensive forced the FARC to the negotiating table. In his home state of Antioquia, the country's second-most populous, the “no” vote won by a whopping 24 points.

In prepared remarks delivered at his ranch outside Medellin, Uribe called for a “big national pact” and insisted on “correctives” that guarantee respect for the constitution, respect for private enterprise and justice without impunity.

“We want to contribute to a national accord,” Uribe said, without explicitly saying whether he supports Santos' call to continue seeking a peace deal with the FARC. “We know that our compatriots who voted 'yes' will listen to us upon receiving our message of good will.”

President Santos served as Uribe's defence minister but the two haven't spoken for years, leading many pundits to joke that bringing the two former allies together is harder than achieving peace with the FARC.

Early in the day, FARC leaders, including Timochenko and Ivan Marquez, sat in leather recliners at Club Havana, once Cuba's most exclusive beach club, watching the referendum results on a flat-screen TV. Initially the atmosphere was festive, with the guerrillas laughing and joking while snacking on cheese-and-olive hors d'oeuvres, smoking cigars and visiting an open bar.

But the mood soured as results began to come in, and the rebel commanders talked in hushed tones on cellphones, conferred quietly and asked journalists to leave the room.

“The FARC deeply regret that the destructive power of those who sow hatred and revenge have influenced the Colombian people's opinion,” Timochenko told reporters later.

He said the rebel group's commitment to peace remains intact.

“The FARC reiterates its desire for peace and our willingness to use only words as a weapon for building the future,” he said.

Turnout was low, with only 37 per cent of the electorate bothering to vote, a further sign to some analysts that Colombians' enthusiasm for the ambitious accord was lacking. Heavy rains from hurricane Matthew especially dampened turnout along the Caribbean coast, where the “yes” vote won by a comfortable double-digit margin.

The campaign exposed deep rifts in Colombia's society, dividing many families and making clear that the road to reconciliation would have been long and torturous even had the accord passed. Colombians overwhelmingly loathe the FARC, which the U.S. considers a terrorist group, and many considered the accord an insult to victims of the long-running conflict.

In the past month, ever since the deal was announced in Cuba after four years of grueling negotiations, the government spent heavily on television ads and staged concerts and peace rallies around the country to get out the vote. It even enrolled the help of U2's Bono and former Beatle Ringo Starr. And for the first time in an election, it made ballots available in Braille so blind Colombians could vote.

The FARC had also made an effort to show its commitment to peace is real. Twice this week leaders of the group travelled to areas hit hard by violence to apologize for massacres committed by their troops and discuss with communities how they can compensate victims. Even ahead of implementation, they voluntarily destroyed in front of United Nations observers 620 kilograms of grenades and light explosives.

-----

AP Writer Michael Weissenstein contributed to this report from Havana, Cuba.