After two weeks of counting votes, Kevin Kiley, a Sacramento-area state legislator, prevailed in a close contest over a Democratic newcomer, Kermit Jones, in a newly redrawn district.