President Juan Manuel Santos of Colombia and the leader of the country’s largest rebel group said Wednesday that they were close to completing a peace deal to end Latin America’s longest-running guerrilla war, announcing that they had reached breakthroughs on some of the most difficult issues dividing the two sides.

“We are adversaries, on different sides, but today we advance in the same direction, the direction of peace,” Mr. Santos said at a news conference in Havana.

The president and the guerrillas, the Revolutionary Armed Forces of Colombia, or FARC, set a six-month deadline to sign a final agreement and the guerrillas agreed to begin handing over their weapons 60 days after a deal is signed.

In announcing his surprise trip to Havana on Wednesday, where the negotiations have been taking place for nearly three years, Mr. Santos said on his Twitter account, “Peace is near.”