Senator Bernie Sanders prevailed over Hillary Clinton on Tuesday in the Oregon primary, according to The Associated Press, while Mrs. Clinton claimed victory in a tight race in Kentucky, the day’s other contest.

Mrs. Clinton raced around Kentucky in the two days before the primary, hoping to fend off Mr. Sanders in a state that she won easily in 2008. In unofficial results late Tuesday night, Mrs. Clinton edged Mr. Sanders by about 1,900 votes, or less than half a percentage point, with all counties reporting. The Associated Press had not declared a winner by midnight.

The close result meant that she and Mr. Sanders would effectively split the state’s delegates. Nonetheless, winning Kentucky would give her a symbolic triumph that could blunt the effect of her loss in Oregon as she turns her attention to Donald J. Trump, her likely general election opponent.