A Kenyan court on Thursday barred the government from lifting a ban on logging but allowed the felling of several thousand hectares of mature forest.

In July, President William Ruto ordered the lifting of the near six-year moratorium despite the concerns of environmentalists, saying it was aimed at creating jobs.

The Environment and Land Court ruled Thursday that the order was "null and void" as there was no public participation before it came into force.

"Petitioners and the members of the public are entitled to participate in the making of laws, regulations and guidelines to govern logging activities," ruled judge Oscar Angote.

The Law Society of Kenya had filed the case after Ruto's announcement, saying the government had not made the scientific case for lifting the ban nor adequately consulted the community about its impact.

Angote however gave the go-ahead for the harvesting of 5,000 hectares (12,355 acres) of mature trees "in strict compliance" with an environment impact assessment report and relevant regulations.

When lifting the ban, Ruto -- who has cast himself as a climate change campaigner -- said it was "foolishness" to let mature trees rot while sawmills were importing timber.

Conservationists fiercely opposed the lifting of the ban, saying it was contrary to Ruto's pledge to plant 15 billion trees and bolster Kenya's forest cover.

In 2018, a government taskforce said the felling of indigenous trees in Kenya's forests was "rampant" and warned 5,000 hectares a year were being cleared.

Meanwhile, Environment Minister Soipan Tuya said on Thursday that 23 Kenya Forest Service officers had been sacked after they were "found to be in gross misconduct through various acts of abetting and conniving with criminals in the destruction of our forests".

Ruto had ordered their dismissal, describing them as "saboteurs" who he did not want in his government.

Forestry and logging contributed 1.6 percent to Kenya's economy last year, according to government statistics, which also said the total forest cover was 8.8 percent in 2022.

Kenya's timber industry employs 50,000 people directly and 300,000 indirectly, according to the government, and the decision to lift the ban came as the economy reels from joblessness and high inflation.