CARTAGENA, Colombia — Colombia’s government and its largest rebel movement signed a historic peace accord Monday in an emotional ceremony that seeks to put an end to a half-century of combat and put the war-weary nation on the path to reconciliation.

President Juan Manuel Santos and Rodrigo Londono, leader of the Revolutionary Armed Forces of Colombia, signed the agreement before a crowd of 2,500 foreign dignitaries and special guests, including U.N. Secretary-General Ban Ki-moon and U.S. Secretary of State John Kerry.

Many in the audience had tears in their eyes, and shouts rose urging Santos and Londono to “Hug, hug, hug!” In the end, the two men just clasped hands and smiled effusively. Then Santos removed from his lapel a pin shaped like a white dove that he’s been wearing for years and handed it over to his former adversary, who fastened it on his own shirt.

It was one of many symbolic gestures that filled the 90-minute ceremony held at sunset overlooking the historic ramparts of Cartagena, nicknamed the “Heroic City” for its prominent role in Colombia’s battle for independence from Spain.

The event kicked off with Santos unlocking with a metal key a giant door, representing a new beginning, through which 15 Latin American presidents and the two sides’ negotiating teams crossed while taking their seats on the stage. All guests were told to wear white and Santos and Londono signed the 297-page accord with pens made from recycled shells used in combat.

Borrowing phrases from Colombia’s 19th century national anthem, Santos, who for years was the FARC’s top military opponent, proclaimed that the signing of the accord will put an end to generations of bloody combat that has killed more than 220,000 and displaced millions, creating the conditions for wounds to heal and the country to prosper in the years ahead.

He led the crowd in chants of “No more war! No more war! No more war!” and urged Colombians to ratify the accord in an Oct. 2 national referendum that will determine its fate.

Addressing the FARC leaders on stage, Santos said, “When you begin your journey back to society, when you begin your conversion into a political movement, I, as head of state of the fatherland we all love, want to welcome you to democracy.”

Londono, best known by his alias Timochenko, called Santos “a courageous partner” and hailed the accord as not only a victory for Colombia but an example to war-ravaged Syria and the Palestinians and Israelis of what can be achieved through dialogue.

He said the FARC wouldn’t abandon its fight for social justice or harsh critique of Colombian elites as it makes its transition into a political movement. But he said it would now defend its political ideals at the ballot box.

“Let no one doubt that we are going into politics without weapons,” Londono said. “We are going to comply (with the accord) and we hope that the government complies.”

He also praised FARC’s fighters as heroes of the downtrodden and then in an emotional high point called out for forgiveness of the FARC’s crimes, which range from kidnapping of civilians to its laying of land mines that have claimed thousands of victims.

“I apologize for all the pain that we have caused,” he said.

The ceremony mostly went off without a hitch although an apparently unexpected low flyover by three fighter jets momentarily startled Londono, who resumed his speech with a joke: “This time they came to salute peace instead of unload bombs.” Londono took over as the FARC’s commander in 2011 after an aerial attack killed his predecessor, known as Alfonso Cano, shortly after he authorized a secret backchannel dialogue with the government.

Across the country Colombians celebrated with a host of activities, from peace concerts to a street party in the capital, Bogota, where the signing ceremony was broadcast live on a giant screen.

The signing was greeted with wild cheers by about 1,000 FARC rebels in the Yari Plains, a remote area of southern Colombia where the group recently concluded its last congress as a guerrilla army by endorsing the deal.

“Yes, we can; yes, we can; yes, we can,” they shouted, followed by calls for Timochenko to be president.

Earlier in the day, government officials attended a Mass celebrated by Cardinal Pietro Parolin, the Vatican’s secretary of state, who praised Colombians for overcoming the pain of the bloody conflict to find common ground with the rebels.

“All of us here today are conscious of the fact we’re at the end of a negotiation, but also the beginning of a still open process of change that requires the contribution and respect of all Colombians,” the cardinal said.

Colombians will have the final say on endorsing or rejecting the accord in the Oct. 2 referendum. Opinion polls point to an almost-certain victory for the “yes” vote, but some analysts warn that a closer-than-expected finish or low voter turnout could bode poorly for the tough task the country faces in implementing the ambitious accord.

Among the biggest challenges will be judging the war crimes of guerrillas as well as state actors. Under terms of the accord, rebels who lay down their weapons and confess their abuses will be spared jail time and be allowed to provide reparations to their victims by carrying out development work in areas hard hit by the conflict.

That has angered some victims and conservative opponents of Santos, a few hundred of whom took to the streets Monday to protest what they consider the government’s excessive leniency toward guerrilla leaders responsible for atrocities in a conflict fueled by the cocaine trade.

To shouts of “Santos is a coward!” former President Alvaro Uribe, the architect of the decade-long, U.S.-backed military offensive that forced the FARC to the negotiating table, said the peace deal puts Colombia on the path to becoming a leftist dictatorship.

The domestic opposition contrasts with widespread acclaim abroad for the accord. On Monday, European Union foreign policy coordinator Federica Mogherini said that with the signing of the peace agreement, the EU would suspend the FARC from its list of terrorist organizations.

Asked whether the U.S. would follow suit, Kerry was less willing to commit but expressed a possible openness to similar action. “We clearly are ready to review and make judgments as the facts come in,” he told reporters. “We don’t want to leave people on the list if they don’t belong.”

The FARC was established in 1964 by self-defense groups and communist activists who joined forces to resist a government military onslaught. Reflecting that history, the final accord commits the government to addressing unequal land distribution that has been at the heart of Colombia’s conflict.

As part of the peace process, the FARC has sworn off narcotics trafficking and agreed to work with the government to provide alternative development in areas where coca growing has flourished.

Only if the accord passes the referendum will the FARC’s roughly 7,000 fighters begin moving to 28 designated zones where, over the next six months, they are to turn over their weapons to U.N.-sponsored observers.

“This is something I waited for my whole life — that I dreamed of every day,” said Leon Valencia, a former guerrilla who is one of the most respected experts on Colombia’s conflict.

Associated Press writers Vivian Salama and Pedro Mendoza in Cartagena, Cesar Garcia in Yari Plains and Libardo Cardona in Bogota contributed to this report.

Joshua Goodman is on Twitter: . His work can be found at .