The electoral transition went smoothly, but what followed did not. Mr. Chiluba began depicting his predecessor as a dictator who had ruined the country, blaming him for Zambia’s economic troubles. Offended, Mr. Kaunda returned to politics, to run against Mr. Chiluba in 1996. But Mr. Chiluba was able to block Mr. Kaunda’s candidacy in the courts. Then, in 1997, as Mr. Kaunda was on his way to a political rally, gunmen fired into his car, wounding him — a bullet grazed his forehead — and a party worker. Mr. Kaunda told reporters that he had been warned that those in power had marked him for assassination.

Later that same year, several junior officers set off a three-hour disturbance that the government accused Mr. Kaunda of having ordered as an attempted coup. He was placed under house arrest. The charges were dropped several months later, but in March 1999, Zambia’s highest court, ruling in a case that had been brought by Mr. Chiluba’s government under nationality laws introduced in 1996, stripped Mr. Kaunda of his citizenship, saying he was not entitled to it because his parents had been born in Nyasaland, a British protectorate that is now Malawi. The authorities threatened to deport him.

Their threat was ultimately not carried out, but the court ruling effectively excluded Mr. Kaunda from contesting further presidential elections, which were limited to citizens whose parents had been born within Zambia’s frontiers.

His travails did not end there.

In November of that year, four gunmen shot and killed his 47-year-old son, Wezi, in the driveway of his home in Lusaka. The younger Mr. Kaunda, a retired army major, had been a rising figure in his father’s opposition United National Independence Party. The authorities described the episode as a carjacking, but many suspected assassination.

Kenneth David Kaunda was born on April 28, 1924, at a Church of Scotland mission in the northern part of what was then Northern Rhodesia. His father, David, had been ordained in the church and worked at the mission as a teacher. His mother, Helen (Nyirenda) Kaunda, had been one of the first African teachers in the region.

Kenneth, the youngest of six children to survive childbirth, was born in the 20th year of his parents’ marriage. They nicknamed him Buchizya, or “unexpected one.”