Former Kenyan President Daniel arap Moi, the country's longest-serving leader, has died aged 95.

The death of Moi, who ruled Kenya from 1978 to 2002, was announced by President Uhuru Kenyatta in a statement carried by the state broadcaster on Tuesday.

More:

"It is with profound sadness and sorrow that I announce the passing of a Great African Statesman, H.E. Daniel Toroitich arap Moi, the Second President of the Republic of Kenya," the announcement said.

"His Excellency the Former President passed on at the Nairobi Hospital on the early morning of this 4th February, 2020, in the presence of his family," it said.

Kenyatta ordered a period of national mourning until a state funeral is held, on a date not yet announced.

Moi had been in hospital for more than a month.

Moi, a former schoolteacher, had been in a Nairobi hospital for over a month before his death [Sayyid Azim/ AP]

Al Jazeera's Catherine Soi, reporting from Kakamega in western Kenya, said opinion on how people will remember the former leader is divided.

"Some people say he started off well in his presidency. He kept the country relatively stable when neighbouring countries were in conflict. He was very passionate about education and built many schools. He was also passionate about the environment and oversaw many tree-planting projects," Soi said.

"Other people will say all that was overshadowed by his reign of terror, detention of political opponents. Several of them died during his time in office," she added.

24-year reign

Despite being called a dictator by critics, Moi enjoyed strong support from many Kenyans and was seen as a uniting figure when he took power after founding President Jomo Kenyatta died in office in 1978.

Some allies of the ailing Kenyatta, however, tried to change the constitution to prevent Moi, then the vice president, from automatically taking power upon Kenyatta's death.

Wary of any threat during that uncertain period, Moi fled his Rift Valley home when he heard of Kenyatta's death, returning only after receiving assurances of his safety.

"Nobody thought he was going to last long in power. He became president to fill in a gap," Lydia Muthuma, an historian at Technical University of Kenya, told Al Jazeera.

"But after an attempted coup in 1981, we saw Moi's true colours. He made sure we understood who was in charge. The news bulletins always started with what he did on the day. He was not a tolerant leader," she added.

In 1982, Moi's government pushed a constitutional amendment through parliament that made Kenya effectively a one-party state. Later that year, the army quelled a coup attempt plotted by opposition members and some air force officers. At least 159 people were killed.

Moi's government then became more heavy-handed in dealing with dissent, according to a report by the government's Truth, Justice and Reconciliation Commission that assessed his rule.

Political activists and others who dared oppose Moi's rule were routinely detained and tortured, the report said, noting unlawful detentions and assassinations, including the killing of a foreign affairs minister, Robert Ouko.

"The judiciary became an accomplice in the perpetuation of violations, while parliament was transformed into a puppet controlled by the heavy hand of the executive," the report said.

Corruption, especially the illegal allocation of land, became institutionalised, the report said, while economic power was centralised in the hands of a few.

In 1991, Moi yielded to demands for a multi-party state due to internal pressure, including a demonstration that year during which police killed more than 20 people, and external pressure from the West.

Multi-party elections in 1992 and 1997 were marred by political and ethnic violence that critics asserted were caused by the state.

By the time Moi left power in 2002, corruption had left Kenya's economy, the most developed in East Africa, with negative growth. Kenyans later voted for a new constitution that was implemented in 2010.

Moi often blamed the West for bad publicity and the economic hardships many Kenyans had to endure during his rule.

As with his predecessor, Kenyatta, many government projects, buildings and currency notes and coins were named after Moi.