Kenneth Kaunda, Zambia’s first president and one of the last surviving leaders of Africa’s 20th-century struggles for liberation from colonial rule, has died aged 97.

President Edgar Lungu’s government said on Thursday that Kaunda, “our beloved founding father, icon and global statesman”, had died in Lusaka, capital of the southern African nation that he led from independence in 1964 until the restoration of multi-party elections ended his one-party rule in 1991.

The authorities have declared 21 days of national mourning for a man who governed with an iron fist for decades but subsequently became an example to the region’s ruling strongmen when he allowed elections, accepted his people’s verdict and peacefully left power.

Kaunda was born in 1924, in the same year as his future fellow liberation-leader-turned-autocrat, Zimbabwe’s Robert Mugabe. The men grew up in different halves of the then British Rhodesian territories.

Both had religious backgrounds and met the indignities of white minority rule with civil disobedience and involvement in African liberation politics.

Mugabe would end up waiting much longer for power. By 1960, Kaunda headed a new force, the United National Independence Party, and was an internationally known figure. He toured the US during its civil rights struggle, meeting black rights activists Malcolm X and Martin Luther King.

At independence, Kaunda led a nation with enviable mineral wealth and a commitment to unity under his phrase “One Zambia, One Nation”. Today it remains Africa’s second-largest copper exporter and one of the region’s most peaceful countries.

He became a legend of liberation to many Africans alongside Mozambique’s Samora Machel and Tanzania’s Julius Nyerere. With Zambia located next to Ian Smith’s Rhodesia and on the front lines of the struggle against apartheid South Africa, Kaunda hosted regional exiles including leaders of South Africa’s African National Congress.

In power Kaunda preached his own brand of African socialism, but his government’s 1969 takeover of Zambia’s copper mines was among the most ill-timed nationalisations in history. Copper prices collapsed during the oil crisis of the 1970s, leaving the country with surging debts and mounting economic turmoil.

Zambia avoided a descent into civil strife or war but a paranoid Kaunda hardened politically and declared one-party rule in 1972. It would last for decades as Kaunda manipulated both his party and successive votes.

But his rule gradually crumbled as ordinary Zambians increasingly rejected it and what had been a promising African economy faltered. Bread riots and mass protests in 1990 were a turning point.

Kaunda allowed other candidates to compete against him in elections the following year, only to be trounced at the polls. He accepted that Frederick Chiluba’s Movement for Multiparty Democracy had ended his 27-year reign. Despite later abortive attempts to try him for treason and remove his citizenship, Kaunda left politics and became a regional elder statesman.

Kaunda’s exit was at the time an unusual act in southern African politics, especially as Mugabe’s ruling Zanu-PF across the border was tightening its grip on Zimbabwe.

But it was an important precedent for moving the region beyond the ageing liberation movements that still control much of southern Africa, including Zanu-PF and Mozambique’s Frelimo.

Despite concerns about authoritarian drift under Lungu, Zambians will embark on another presidential vote this year. Kaunda’s former party, long since out of power, will barely feature in the running.