A Kenyan court ordered police on Tuesday to detain eight pro-government and opposition politicians for investigation over alleged "hate speech", flagging growing tensions more than a year before elections and after weeks of deadly protests.

Ethnic loyalties tend to trump policy matters in Kenyan politics. After a disputed election in December 2007, incitement by rival camps was blamed for stoking bloodletting between major ethnic groups that left 1,200 dead and hundred of thousands displaced.

However, incidents of politicians drumming up support or stoking fears based on ethnic allegiances continue to crop up in recordings or speeches on the internet, worrying many who fear renewed violence in the August 2017 race.

Police took the eight to court after they were alerted to remarks by four pro-government politicians and four from the opposition. The police said the remarks were "said to be laced with ethnic hatred, vilification and border on incitement."

Chief Magistrate Daniel Ogembo said he had authorised the detention of the eight for four day. He said the prosecution had shown the suspects were influential and that they could interfere with the investigation.

Ogembo said the eight must return to court on June 17 for further directions.

On the opposition side, the politicians named included Aisha Jumwa from the coastal region and Timothy Bosire, a lawmaker from western Kenya, an opposition stronghold.

On the pro-government side, politicians included Ferdinand Waititu, a lawmaker now challenging for a county governorship near Nairobi, and Moses Kuria, a lawmaker who represents a constituency formerly held by President Uhuru Kenyatta.

The 2017 presidential election is expected to pit Kenyatta, a Kikuyu - the biggest of Kenya's more than 40 ethnic groups - against Raila Odinga, a Luo, another major ethnic grouping. Kenya will also hold elections for parliament, governors and county assemblies next year.

Odinga disputed the 2007 and 2013 election results, losing the latter to Kenyatta. Since late April, he has led a series of almost weekly protests against an electoral oversight body his supporters accuse of pro-government bias. The oversight body denies this.

At least four people have been killed in the protests so far, in which demonstrators have often clashed with police.