According to Kenya's internal security ministry, the officers were attacked around 4 a.m. Saturday in Samburu North, an arid, sparsely populated district several hours north of Nairobi, the capital. The ministry said that the officers were trying to recover stolen livestock when they were waylaid by bandits from the Turkana ethnic group, one of the poorest, most marginalized groups in Kenya, with a reputation for being fierce pastoralists.

A wildlife specialist, who works closely with the police and spoke on the condition of anonymity because he did not want to imperil his relations with the police force, said officers had tracked the stolen animals to a valley called Lokorkor, which has only one way in and one way out. Herders in the area call it Death Valley.

"If the enemy gets there before you, then you are done," he said.

He said the Turkana cattle rustlers occupied the higher ground leading into the valley and waited in the dark for the police officers to file in. Then, the rustlers opened fire on the officers below.

"Everything went wrong, everyone went in different directions, and the officers didn't know the area that well and therefore ran into more ambushes," the wildlife specialist said. "The Turkana didn't have any mercy on them and killed everyone who wasn't Turkana."

The Kenyan government issued a statement on Sunday saying that at least 11 officers were shot to death and 7 were seriously wounded. The government also said it was sending more officers to the area to "apprehend the bandits to restore peace and security."

On Monday, several Kenyan news media organizations reported that more bodies had been discovered, bringing the death toll for the police to 31.

Citizen News, one of the country's biggest television stations, called it a "massacre," and the BBC reported that the episode was the deadliest attack on the Kenyan police since the country became independent in 1963.

Cattle rustling and livestock theft are dangerous, stubbornly ingrained facts of life for many young men in northern Kenya who see such raids as a badge of honor. Scores of people are killed each year in battles over cows, goats and camels, and the government is often criticized for not doing enough to intervene.

At the same time, elders from pastoralist communities in Kenya also routinely complain about fierce crackdowns by the police. In the past, especially after an officer has been killed, security forces have swept into villages, and many villagers have been killed in the ensuing battles.

Reuben Kyama contributed from Nairobi, Kenya.