The result is a flood of pastoralists from miles away who say they have no place to graze their animals but inside Nairobi’s city limits, which is illegal. They often get in tangles with the law, having to bribe their way out of jail.

“I’ve been arrested more times than I can count,” said David Kamau, another urban shepherd.

Kenyan officials say urban grazing is bad for many reasons, not least for maintaining order.

“You can’t tell animals to keep left or keep right,” said Eric Kiraithe, a government spokesman.

The clash is the worst during the dry season, which is tapering off right now, when the shrinking amount of pastureland shrivels into yellow straw and the rural areas ringing Nairobi turn into dead country. That’s when herds flock in from all directions to munch the lush lawns and parkways.