Namibia's President Hage Geingob died early Sunday in a hospital in Windhoek, his office said. He was 82.
Geingob, who was serving his second term as president and was his country's first prime minister after independence, revealed last month that he was being treated for cancer.
Most recently, he took a stand by supporting South Africa's complaint against Israel under the Genocide Convention and by condemning Namibia's former colonial ruler Germany for rejecting the case.
"It is with utmost sadness and regret that I inform you that our beloved Dr. Hage G. Geingob, the President of the Republic of Namibia, has passed on today," read a statement signed by acting president Nangolo Mbumba.
"At his side, was his dear wife Madame Monica Geingos and his children."
A biopsy following a routine medical check-up in January had revealed "cancerous cells", Geingob's office said at the time.
President Cyril Ramaphosa of South Africa said: "Today, South Africa joins the people of our sister state Namibia in mourning the passing of a leader, patriot and friend of South Africa.
"President Geingob was a towering veteran of Namibia's liberation from colonialism and apartheid. He was also greatly influential in the solidarity that the people of Namibia extended to the people of South Africa so that we could be free today."
President William Ruto of Kenya echoed this praise.
"He was a believer of a unified Africa and strongly promoted the continent's voice and visibility at the global arena," he said.
First elected president in 2014, Geingob was Namibia's longest-serving prime minister and third president.
In 2013, Geingob underwent brain surgery, and last year he had an aortic operation in neighboring South Africa.
Up until his death, he had been receiving treatment at Lady Pohamba Hospital in Windhoek.
"The Namibian nation has lost a distinguished servant of the people, a liberation struggle icon, the chief architect of our constitution and the pillar of the Namibian house," said Mbumba.
"At this moment of deepest sorrow, I appeal to the nation to remain calm and collected while the government attends to all necessary state arrangements, preparations and other protocols."
He said the cabinet would convene immediately to make the necessary state arrangements.
Independence struggle
Born in a village in northern Namibia in 1941, Geingob was the southern African country's first president outside of the Ovambo ethnic group, which makes up more than half the country's population.
In his early years he took up activism against South Africa's apartheid regime, which at the time ruled over Namibia, and in 1964 he was appointed representative for the SWAPO liberation movement at the United Nations.
He spent almost three decades in Botswana and the United States, returning to Namibia in 1989 to lead SWAPO's election campaign in his now independent homeland.
Namibia is to hold presidential and national assembly elections towards the end of the year.