Mr Ruto and his family were not at the compound near the western city of Eldoret at the time.
The man had entered the residence after injuring a police guard with a machete and stealing his gun, police said.
The incident comes days before Kenya holds presidential elections.
Police chief Joseph Boinnet told local media the situation was now "under control".
"There is no threat now because he was the only one."
There were no further details about the attack.
Earlier reports suggested a number of gunmen had entered Mr Ruto's home, but police later clarified there was only one attacker.
More about Kenya's elections:
Full coverage here
There have been conflicting reports about how many guns the attacker used.
Mr Boinnet told Capital FM News that only one firearm, belonging to the security guard, had been recovered from the gunman.
However, Rift Valley Regional Co-ordinator Wanyama Musiambo told reporters the attacker had used a number of guns after breaking into a police armoury in the compound.
"From the exchange of fire we thought it was more than one attacker, because he used different firearms," he said in quotes carried by Reuters news agency.
"After the operation we discovered that it was one gunman, but because he was inside there, he could change positions and firearms because he had access to the guns. And the guns he was using were ours," he added.
The deputy president had left the home hours before the attack, heading to a campaign rally in the town of Kitale with President Uhuru Kenyatta.
Mr Kenyatta is seeking re-election on 8 August. Legislative and regional elections will also be held on the same day.
While Kenya's 2013 elections passed relatively peacefully, there was serious post-election violence following the 2007 polls, which left more than 1,000 people dead and 600,000 displaced from their homes.
However, experts say they do not expect to see the same level of conflict in the coming elections.
Kenyan police say they have shot dead an attacker who forced his way into the rural home of Kenya's Deputy President William Ruto, ending a siege that lasted several hours.