JOHANNESBURG — Mozambique’s president and the leader of country’s main opposition group signed a new peace accord Tuesday, pledging to end years of violence and work toward peaceful elections in October.

The signing of the Peace and National Reconciliation Agreement in the country’s capital, Maputo, by President Filipe Nyusi and Ossufo Momade, the leader of the Renamo rebel group, followed their signing last week of a similar agreement to cease military hostilities. That took place in Gorongosa National Park in central Mozambique.

The new pacts call for the immediate disarmament and reintegration into society of more than 5,000 rebels. Some Renamo officers are to take up leadership positions in the military, but only a few rebels have turned in their arms so far. Mr. Momade said they would participate peacefully in the country’s elections on Oct. 15.

As part of the negotiations, Mozambique’s legislature amended the country’s constitution so provincial governors will be elected, rather than appointed by the ruling party. It is expected this change will allow Renamo to win a few provincial governor positions in central and northern areas where it has support.