HAVANA – In a ceremony meant to mark the symbolic end to 52 years of fighting, Colombian President Juan Manuel Santos and leftist guerrilla commander Timoleón Jiménez shook hands on a cease-fire pact Thursday that paves the way for a final peace deal and the rebels’ complete disarmament.

With U.N. Secretary General Ban Ki-moon and six Latin American presidents in attendance, Santos and Jiménez celebrated the deal — which overcomes the last major obstacle to a larger peace accord — as a historic moment for a country that has been at war with itself for the past five decades.

“This is the end point of the armed conflict,” said Santos.

“May this be the last day of the war,” said Jiménez, leader of the Revolutionary Armed Forces of Colombia (FARC), who is better known by the nom de guerre Timochenko.

Santos said this week he wants to sign a final peace accord in time for Colombia’s July 20 independence anniversary, but officials with knowledge of the talks say it will likely take longer to iron out the last few details and that a signing ceremony in August is a more realistic target.

Still, the agreement signed Thursday essentially maps out the complex choreography of getting 7,000 heavily armed rebel fighters to leave their jungle camps, lay down their guns and turn their insurgency into a legal political movement. With drug trafficking gangs and other armed criminal groups still powerful in parts of rural Colombia, the rebels retain deep fears that they will be left defenseless to attacks from their longtime enemies, despite assurances that government security forces will protect them.

But after 3 1/2 years of formal negotiations, the most delicate aspects of the peace talks have been settled.

“There is nothing big and substantial left that will pull the two parties apart,” said Bernard Aronson, the U.S. special envoy to the Colombian peace process, who also attended Thursday’s ceremony.

“The finish line has been defined,” said Aronson. “Absent some unanticipated extraneous event, this is the end of the war.”

The conflict has killed an estimated 220,000 people and forced nearly 7 million Colombians from their homes over the decades — the highest number of what the United Nations considers “internally displaced persons” in the world.

Santos said Thursday that a final peace accord will be signed in Colombia. The accord will then be subject to approval by Colombian voters through a referendum. While government negotiators and the FARC had been at odds over the form the referendum would take, they announced Thursday that the plebiscite would be defined by Colombia’s judiciary — meaning that the rebels accepted the government’s position.

For the FARC, the most difficult part of the peace process essentially boiled down to two highly sensitive issues.

The rebels did not want a peace deal that would put them in prison. And they refused to give up their guns if it meant they would be exposed to bloody payback from their enemies.

They reached an agreement last year on the first point. Essentially, FARC rank-and-file members whose only formal criminal charge is “rebellion” will receive a blanket amnesty.

FARC leaders with convictions in absentia or who are charged with serious crimes — including terrorism, murder, kidnapping and drug trafficking — will be eligible for an alternative judicial process.

If they agree to testify to crimes and fully disclose their roles in the conflict, they will be eligible for sentences that are less punitive than prison and resemble something closer to community service. But if they withhold information or do not tell the truth, they could be tried by Colombia’s criminal justice system and face the risk of lengthy terms in conventional prisons.

Critics of Santos and the peace deal say that amounts to a wrist-slap for FARC commanders and a betrayal of the conflict’s victims.

Under the terms of the agreement announced Thursday, the rebels will gather in 22 protected zones and eight camps, where they will disarm in phases once the final accord is reached. Colombian security forces will provide security, but unarmed U.N. observers will be present in the camps with the rebels to oversee the process.

FARC fighters will begin by giving up heavy weapons, followed by rifles and, eventually, sidearms. The process could take up to 180 days, during which only a limited number of FARC personnel would be allowed to leave the zones, and no civilians would be allowed to enter them without government approval.

“The idea that the FARC would concentrate its forces and lay down its weapons in exchange for security guarantees was always the goal in theory,” said Cynthia Arnson, director of the Latin America program at the Woodrow Wilson Center for International Scholars in Washington. “But agreeing on the concrete steps to make it happen is just huge,” she said.

“There’s no doubt that the hardest part — implementation of the accords — is yet to come,” said Arnson. “But recognizing that shouldn’t detract from what a transcendental moment this is.”

With Santos’s public approval ratings sliding and impatience with the peace talks among the Colombian public, the government has done little to conceal its eagerness to close the deal.

The FARC has proceeded more cautiously, knowing that the terms of its disarmament are the last card it holds at the bargaining table. But sources close to the talks say FARC leaders are eager to jump into Colombian electoral politics, with members of its negotiating team hoping to enter congress when Colombia holds its next elections in 2018.

The presidents of Mexico, Venezuela, Chile, El Salvador and the Dominican Republic also attended Thursday’s ceremony.