Violence has convulsed the nation, with police warning those living in the city's slums that they will be shot dead if found outside their homes.
A curfew is also being enforced in the city of Kisumu, with officers ordered to gun down any violators.
Chaos erupted soon after President Mwai Kibaki's controversial re-election on Sunday.
Opposition leader Raila Odinga, who claims the vote was rigged, has compared Mr Kibaki to a military dictator.e said: "There is no difference between him and Idi Amin and other military dictators who have seized power through the barrel of the gun."
Twenty-one bodies have been delivered to a hospital mortuary in the western city of Kisumu, most with bullet wounds, witnesses said.
But police said the death toll in capital Nairobi has risen to 40 after initial reports of 15 bodies being found scattered across the city's Korogocho slum.
Opposition supporters have been burning houses in the area, as police fired tear gas to disperse angry crowd.
Lawrence Ochieng, a resident in the slum, said: "We are fighting Kikuyu (a Kenyan tribe) gangs and we have to kill them all. We have already killed two people."
The government has kept a ban on live TV broadcasts and flooded streets with security forces to try and defuse one of the most volatile moments in Kenya since its 1963 independence.
Mr Kibaki took 4.58 million votes to Mr Odinga's 4.35 million - but the results were marred by accusations of multiple voting, disappeared returning officers and "doctoring".
"The tallying process lacks credibility," chief European Union monitor Alexander Graf Lambsdorff said.