The law, which also doubled the fuel tax and increased the top income tax rate, sparked violent protests in July by opponents who said it would further squeeze households at a time of rising living costs.
In its ruling, the court said the government had not provided a rational explanation for why it had imposed the housing levy only on workers with employment in the formal sector.
"The introduction of the housing levy... is discriminatory and irrational and arbitrary and is in violation... of the constitution," Judge David Majanja said.
The judges then approved the government lawyers' request for a 45-day stay of the order as they decide whether to appeal or make changes to the law to address the judges' concerns.
President William Ruto's government has argued higher taxes are necessary to stabilise government finances, which have been hit by growing debt repayments, and to expand access to housing.
Reuters, the news and media division of Thomson Reuters, is the world's largest multimedia news provider, reaching billions of people worldwide every day.Go to: https://www.reuters.com/