A man armed with a machete attacked the country home of Kenya's deputy president and injured a guard before holing himself up in an outbuilding, police said on Saturday, 10 days before presidential and legislative elections.

Deputy President William Ruto was out with his family at the time of the attack in the town of Eldoret, about 312km northwest of the capital Nairobi.

Ruto is the running mate of President Uhuru Kenyatta, who is seeking a second and final term in office in the August 8 elections.

"In circumstances that are yet unclear, he hit an officer on duty ... with a machete and managed to enter a farm complex," Inspector General of Police Joseph Boinnet said in a statement, adding that officers were still trying to arrest the assailant.

"The injured officer is undergoing treatment and is in a stable condition," Boinnet said, adding that Ruto's house was secure.

"Other officers were quickly mobilised and the intruder was forced to hide at a building that is still under construction next to the gate," Boinnet said.

Local television stations had reported earlier that gunmen were behind the attack on Ruto's home, with NTV News and KTN News reporting that gunshots were heard at the scene.

Typically, the deputy president's residence is guarded by an elite paramilitary police unit.

INTERACTIVE: How do the Kenyan elections work?

A spokesman for Ruto declined to comment but the security official said the vice president had left the house shortly before the attack to attend a rally alongside President Uhuru Kenyatta, his running mate who faces a tight re-election contest on August 8 against longtime opposition leader Raila Odinga.

Ruto's home sits in Kenya's western Rift Valley area, the flashpoint for an outbreak of election violence after the disputed 2007 polls that killed 1,100 people and tarnished Kenya's image as a regional beacon of safety and stability.

According to opinion polls, this year's election will be close and tensions have been rising.

Odinga has repeatedly claimed the government is scheming to steal the election, while Kenyatta has accused Odinga of trying to delay the polls.

Threats and voter intimidation

Earlier this month, Human Rights Watch said it had received reports of threats and voter intimidation in Naivasha, a flashpoint town in 2007 and one of the potential hotspots in this year's election.

In the Rift Valley, hate speech flyers have been circulating and some local residents have already left their homes.

The 2007 bloodshed haunted both Ruto and Kenyatta long after it ended, when the International Criminal Court put both on trial for orchestrating the violence.

Those charges were later dropped, with ICC chief prosecutor Fatou Bensouda blaming a relentless campaign of victim intimidation for making a trial impossible.

Source: News agencies