The Environment and Land Court has issued temporary conservatory orders stopping the planned eviction of Makongeni residents.
The government had ordered residents of the area to vacate their premises by December 2 to pave the way for the affordable housing project.
The court issued the conservatory orders after Otieno Willis Evans Otieno, on behalf of several Maongeni residents, filed a petition to prevent the government from continuing with the evictions.
In his petition, Otieno sought the restoration of water and electricity, which were cut to coerce the residents into leaving the place.
The court has now directed the government to ensure that it restores water and electricity to the residents, pending the full hearing of the case.
"The court has now directed the respondents to immediately restore water and electricity and barred them from carrying out any further evictions or demolitions pending the full hearing of the case," Otieno said.
"This is a victory for the people; a reminder that state power has limits and that the Constitution still speaks loudly for the vulnerable when the powerful overreach. Makongeni will not be erased. Not on our watch," he added.
Once the affordable housing units are complete, the government had assured that the residents will be given priority in the purchase of the houses to allow the community to rebuild.
More than 3,000 residents have already received Ksh150,000 to facilitate their relocation; however, the majority have yet to receive compensation, making it difficult for many to move.
The announcement by Otieno comes a day after the Law Society of Kenya (LSK) urged the government to stop the planned eviction and demolition, noting that it contravened their rights. The society threatened to sue the government if it failed to respect the rights of the residents during the eviction.
If the evictions must go on, the society's President, Faith Odhiambo, said that the government should give the residents enough time to relocate their properties.
During the relocation, the society said that authorities should guarantee the protection of vulnerable groups such as women, children, and the elderly.
"Evictions must adhere to certain globally recognised minimum standards, including the duty to give notice in writing and to carry out the eviction in a manner that respects the dignity, rights to life and security of those affected," a statement from the society's President, Faith Odhiambo, said