The woman had been having affairs with both men for more than four years and apparently refused to choose between them.
The agreement sets out a roster for Sylvester Mwendwa and Elijah Kimani to stay in her house and states they will both help raise any children she bears.
Mr Mwendwa told the BBC he loved the woman and said the contract would "set boundaries" and "keep the peace".
Defending the "marriage", Mr Mwendwa told the BBC Focus on Africa program that while he may acting in breach of the law, he had decided to enter into a contract with Mr Kimani to end their rivalry.
"It could have been very dangerous if the other man would have come to her house and caught me... So our agreement is good as it sets boundaries and helps us keep peace."
Mr Mwendwa said her parents had given their blessing, while he is planning to pay the bride price.
The woman, a widow with two children, did not want to be named.