NAIROBI, Kenya (AP) — A lone intruder who managed to enter the home of Kenya's deputy president was killed more than 18 hours after he wounded a police guard with a machete and then killed another with a stolen rifle, Kenya's police chief said Sunday.

The man kept police special forces engaged overnight at Deputy President William Ruto's residence on the outskirts of Eldoret, a town 194 miles (312 kilometers) northwest of Nairobi, Police Chief Joseph Boinnet said.

Ruto was not injured. Kenyan media reported that the intruder gained entry to the home around noon Saturday, moments after Ruto had left to campaign with President Uhuru Kenyatta for re-election.

Once inside the premises, the suspect attacked a police officer with a machete and "inflicted deep cuts on his heads, hands and leg of the officer as he attempted to fight him off," Boinnet said.

The intruder then took the wounded officer's rifle, went into another building and fatally shot an officer who was resting after a night shift, the police chief said.

Analysts have been worried that violence might accompany Kenya's Aug. 8 presidential election. The stakes are very high for the candidates, said Murithi Mutiga, a senior analyst for the horn of Africa at the think tank International Crisis Group.

"Kenyatta, a scion of one of the most prominent political families in the country, does not want to make history as the first Kenyan president not to achieve re-election. His rival, Raila Odinga, son of Kenya's first vice president, is probably making his last serious attempt at capturing the presidency," Mutiga said. "None of them can afford to lose."

Public opinion polls have shown the race tightening in recent weeks.

"Add to that the fact the electoral body is relatively new and has faced many challenges in preparing for the election, and you can understand the anxiety that surrounds the election," he added.

The Islamist extremist group Al-Shabab recently threatened to disrupt the vote.

Al-Shabab has carried out more than 100 attacks in Kenya since 2011 in retribution for the country sending troops into Somalia, where the extremists are based.

Kenya experienced arguably its worst episode of violence 10 years ago after a December 2007 presidential election that international observers said was flawed. More than 1,000 people died and 600,000 were evited from their homes.