Venezuela and Colombia to normalise ties after border row
President Nicolas Maduro of Venezuela and his Colombian counterpart, Juan Manuel Santos, have agreed to "a progressive normalisation" of their common border.
Venezuela closed parts of the border a month ago and launched a major anti-smuggling operation.
Mr Maduro says up to 40% of Venezuelan goods are smuggled out of the country.
Meeting in Ecuador, the two presidents also said they would return ambassadors to each other's capitals immediately.
"Common sense, dialogue and peace between our peoples and our countries have triumphed today," said Mr Maduro after the talks in Quito aimed at defusing the crisis.
The Venezuelan leader ordered the closure on 19 August after three Venezuelan soldiers and a civilian were injured in an attack in San Antonio del Tachira near the border.
He has since extended the measure to a total of three border states.
The closure was first imposed for 36 hours but has since been prolonged indefinitely.
The two sides on Monday agreed to a "normalisation" but did not set a date for a re-opening of the border.
Government officials from both sides are due to meet on Wednesday to work on the details of the "normalisation plan".
More than 1,500 Colombians living illegally in Venezuela were also evicted as part of the anti-smuggling operation.
Another 20,000 are estimated to have left fearing deportation.
Some said they had been mistreated by the Venezuelan security forces, prompting Colombia to recall its ambassador from Caracas in protest.
Venezuela later recalled its ambassador from Bogota.
President Santos said on Monday that Venezuela "should have respected the rights of Colombians" that were forced out.
The 2,200km-long border (1,400 miles) between the two countries is porous and there has historically been a steady flow of people both ways.
It is a haven for smugglers and criminal gangs, as well as Colombia's left-wing guerrilla groups, who often extort local residents.
The Colombian leader said on Tuesday: "I agree that criminal organisations working in the border area are a big problem, but the best way to deal with it is by working together."
The Venezuelan president agreed to investigate allegations that Venezuelan jets violated Colombian air space earlier this month.
The allegations, and their dismissal as a Colombian fabrication by Venezuelan Foreign Minister Delcy Rodriguez, further ratcheted tensions between the two countries.
Monday's talks were facilitated by Uruguayan President Tabare Vasquez and his Ecuadorean counterpart, Rafael Correa.
The summit was preceded by two meetings between the Colombian and the Venezuelan foreign ministers.