Colombians narrowly rejected a peace deal with Marxist insurgents on Sunday, plunging the nation into uncertainty and handing a major defeat to President Juan Manuel Santos, who had staked his reputation on ending the 52-year war.

Before the referendum, Santos, 53, said he had no Plan B and would return Colombia to war if the "no" vote won.

Opinion polls had shown that he would comfortably win and then be able to start implementing the deal, which was painstakingly negotiated in Cuba over the past four years to end the longest-running conflict in the Americas.

But Colombian voters confounded that forecast as the "no" camp won with a razor-thin vote of 50.23 percent to 49.76 percent, with votes counted from 99.59 percent of voting stations.

Opponents of the pact believed it was too soft by allowing the FARC rebels to re-enter society, form a political party and escape traditional jail sentences. They want to renegotiate the deal.

"I voted no. I don't want to teach my children that everything can be forgiven," said Alejandro Jaramillo, 35, who was angered that the rebels would not serve jail time.

Sunday's vote had asked for a simple "yes" or "no" on whether Colombians supported the accord signed last Monday by Santos and the rebel commander known as Timochenko.

The Revolutionary Armed Forces of Colombia, known as FARC, whose numbers were halved to about 7,000 in recent years because of a U.S.-backed military offensive, had agreed to turn in weapons and fight for power at the ballot box, instead.

Influential former President Alvaro Uribe led the "no" camp, arguing that rebels should pay for crimes in jail and never be given congressional seats.

Under the accord, FARC, which began as a peasant revolt in 1964, would have been able to compete in the 2018 presidential and legislative elections and have 10 unelected congressional seats guaranteed through 2026.

It would also have given up its role in the lucrative illegal drug trade and taken part in reforming rural Colombia.

But controversially, many rebel leaders who ordered killings, bombings and displacements would have had to appear before a special tribunal that could have sentenced them to alternative punishments like clearing landmines.

For decades, FARC bankrolled the longest-running conflict in the Americas through the illegal drug trade, kidnapping and extortion, spreading a sense of terror that left few Colombians unaffected. The conflict took more than 220,000 lives and displaced millions of people.

The bloodshed, at its worst, saw FARC positioned close to the capital and the state on the verge of collapse. Battles among the guerrillas, paramilitaries, drug gangs and the army raged in the countryside, and atrocities were committed on all sides.