Former Kenya President Daniel arap Moi, whose 24 years in power were marred by repression of his critics and economic turmoil, died Tuesday at the age of 95.

Moi passed away peacefully in Nairobi after being in and out of hospitals for months, according to his son, Sen. Gideon Moi.

Current President Uhuru Kenyatta ordered national flags to fly half-staff from Tuesday until sunset of the day of the burial.

WHO ARE THE WORLD'S LONGEST-RULING LEADERS?

The man called a dictator by his opposition rose to power in 1978 after the East African country's founding president Jomo Kenyatta died in office.

In 1982, Moi’s government pushed through parliament a constitutional amendment 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, the longest ever in Kenya, then became more repressive 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, according to the Associated Press.

Corruption, especially the illegal allocation of land, became institutionalized, the report added, while economic power was centralized in the hands of a few.

AFRICAN WARLORD ASKS US JUDGE TO OVERTURN 30-YEAR SENTENCE

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

But multiparty elections in 1992 and 1997 were marred by political and ethnic violence that critics asserted were caused by the state.

Moi left office in 2002 after being constitutionally barred from seeking a third term and two years later, asked for forgiveness from "those he had wronged,” the BBC reported.

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

Many government projects, buildings, and currency notes and coins were named after Moi. Fed up, Kenyans voted for a new constitution that was implemented in 2010 and made provisions to bar personality cults.

Mixed reaction greeted Moi's death.

Commentator Patrick Gathara said in a tweet that Tuesday was a day to remember Moi's victims “as well as the thousands who stood against his brutal and murderous kleptocracy. It is a day to remember that the current crop of politicians helped him escape justice for his crimes.”

CLICK HERE TO GET THE FOX NEWS APP

Salim Lone, a former U.N. spokesman who fled into exile because of harassment under Moi, said the former president began so well and “so many supported your promise of a free more inclusive, corruption-free Kenya.” He said that Moi at the beginning of his rule released political prisoners and famously said it was better to eat kale and sleep in peace than seek riches.

“How it went wrong is not for now,” Lone said in a tweet.

The Associated Press contributed to this report.