The Ogiek were entitled to live on their ancestral land and the government should not have tried to evict them, a pan-African court ruled.
Campaigners hailed the ruling as a huge victory for indigenous communities.
The government had argued that the hunter-gatherers needed to be evicted to protect the indigenous forest.
But the African Court of Human and People's Rights ruled that the government had violated a series of rights of the Ogiek people, including the right to property and the right to practise their culture in the forest in western Kenya.
Environmental degradation in the Mau Forest had been caused mainly by "ill-advised" logging concessions and settlement by non-Ogiek people,  Justice Augustino Ramadhani said, according to Reuters news agency.
The ruling affects some 35, 000 traditional hunters who live in the forest, some 200km (125 miles) from the capital, Nairobi.
"They are one of the last remaining forest-dwelling communities and among the most marginalised indigenous peoples in Kenya," said Minority Rights Group International.
"For the Ogiek, this is history in the making. The issue of Ogiek land rights has finally been heard and the case has empowered them to feel relevant," it added in a statement.
One community member, 96-year-old Rashamba Debola, told the BBC she had lived in the forest all her life.
"I grew up here, married traditionally, had my family here, buried my husband in this forest. I don't know anywhere else. For now, I live here with my great-grandchildren. I would love to see them carry on our traditions."
Amnesty International said the hunter-gatherers had fought for a long time in the Kenyan courts, before turning to the pan-African court to achieve justice.
"Today's ruling is a historic victory for the Ogiek community, and gives hope to all indigenous peoples everywhere," it said in a statement.
"But a ruling is not enough, it must be respected. The Kenyan government must now implement the ruling and let the Ogiek live freely on their ancestral land."
The Tanzania-based court's ruling is legally binding, but it cannot sanction countries for non-compliance.
The Mau Forest, covering 273,300 hectares (675,000 acres), is the largest forest of indigenous trees in East Africa.
Hunter-gatherers in Kenya have won an eight-year court battle against the government's plan to evict them from their ancestral land in the Mau Forest.