Afonso Dhlakama, the leader of Mozambique’s main opposition group, who was held responsible for exceptional brutality by its often young soldiers during a civil war that claimed up to a million lives, died on Thursday at his hide-out in the Gorongosa mountains in southeast Africa. He was 65.

The Mozambican authorities confirmed the death but did not specify the cause. News reports said it was either diabetes or a heart attack.

President Filipe Nyusi, who had been negotiating a rapprochement with Mr. Dhlakama, a former guerrilla commander, said he had tried to have him evacuated by helicopter for medical treatment.

“I could not, because he was in a place where I could not help,” the president said.

The impact of Mr. Dhlakama’s death on a frail truce, negotiated in advance of elections scheduled for 2019, was not immediately clear.

Mr. Dhlakama had headed the opposition Renamo movement for almost four decades in Mozambique, a former Portuguese colony. In Portuguese, the group’s initials stand for Mozambique National Resistance.

Mr. Dhlakama had fought briefly with the Soviet-backed and avowedly Marxist insurgents who took power when Mozambique gained independence in June 1975. But he defected soon afterward and joined a dissident group opposed to the dominant movement, Frelimo (Mozambique Liberation Front), led by Samora Machel, the first president of independent Mozambique.

During the civil war against the leftist government in Maputo, which began in 1977 and ended in 1992, Renamo was cast as an international pariah, little more than a pawn in the Cold War-era conflicts that ended white minority rule across southern Africa.

The group was established with the support of white intelligence officers in neighboring Rhodesia, now called Zimbabwe; they saw Renamo as a means of undermining Mozambique’s role as a base for Zimbabwean nationalist guerrillas led by Robert Mugabe.

With Zimbabwean independence in 1980, white-ruled South Africa took over as the chief covert backer and arms supplier to Renamo, using it once more as a force of destabilization — this time against President Machel’s support for the anti-apartheid African National Congress, which was operating in exile from Mozambique and elsewhere.

In 1984, President Machel was forced to sign a treaty with South Africa — named the Nkomati Accord for the area where it was signed — in which he offered to withdraw support for the A.N.C. in return for South Africa’s ending its sponsorship of Renamo. The agreement was broken often by both sides, and it was not until South Africa’s white rulers finally pledged to abandon apartheid that Renamo opened peace talks with the leadership in Maputo.

By that stage, the two sides had fought to a stalemate in a bush war characterized by massacres, rape and looting. At the same time, the distant world beyond the conflict was changing fundamentally as the Cold War drew to a close.

In 1988, the United States State Department sponsored a report accusing Renamo of widespread atrocities, including forced labor and arbitrary executions. The report, likening Renamo to the Khmer Rouge in Cambodia, accused Mr. Dhlakama’s troops — some of them child soldiers — of a string of massacres, including one at Homoine, in which more than 400 civilians died. Mr. Dhlakama denied the accusations, insisting that government forces had staged atrocities to discredit the dissidents.

“If we were just a bunch of bandits, we would have been caught and been handed over to government forces long ago,” he said in an interview with The New York Times in 1988. “Our aim is not to win the war militarily but to force the Frelimo government to accept our conditions” for establishing democracy.

Afonso Dhlakama was born on Jan. 1, 1953, in the Sofala Province of central Mozambique, the son of a traditional ruler. He was educated by Roman Catholic seminarians in the Indian Ocean port city of Beira, according to “The Battle for Mozambique,” a study by Stephen A. Emerson, an American analyst of African affairs.

Mr. Dhlakama was conscripted into the Portuguese colonial army but deserted to join Frelimo. When he defected to Renamo, Mr. Emerson wrote, the Frelimo authorities said Mr. Dhlakama had been dismissed for corruption and misconduct — allegations he denied.

Mr. Dhlakama rose rapidly through the Renamo ranks, and when its leader, André Matsangaissa, was killed in action in 1979, he took over the organization and presided over the expansion of its ragtag army into a force numbering up to 20,000 guerrillas.

In his 1988 interview, Mr. Dhlakama said the guerrillas’ hit-and-run strikes against towns held by the Mozambican Army were designed “to demoralize and lower the profile of the enemy” rather than hold territory. “It serves no purpose to hold towns that are empty,” he said. His forces also struck at vital regional transport links.

Renamo was always hostage to events beyond its control. As South Africa’s support for the dissidents dwindled, the Frelimo government drew on backing from Zimbabwean, Tanzanian and Zambian troops, and persuaded a key supporter, Malawi, to cease aiding the rebels in 1986. For all that, Renamo’s control of so-called liberated rural areas turned many remote towns into islands of government control, reachable only by air.

In 1992, Mr. Dhlakama signed a peace treaty with the Mozambican president, Joaquim Chissano; after a blanket amnesty, Renamo became a legal political party but retained its guerrilla force. In successive presidential elections — Mr. Dhlakama contested all of them — the government’s candidates won every vote, and in 2013, Renamo said it was abandoning the 1992 peace accord.

Mr. Dhlakama left Maputo and returned to his wartime hide-outs in Gorongosa, losing yet another presidential election in 2014 and facing a string of assassination attempts.

He announced a truce in 2016 and a year later held talks with President Nyusi aiming at a reconciliation with Frelimo, which has held power without interruption since Mozambique’s independence.

Following the death of Mr. Dhlakama, President Nyusi called him “a citizen who always worked for Mozambique,” news reports said.

“I hope,” he added, “that we as Mozambicans can continue to do everything so things do not go down.”