Former U.S. Secretary of State Hillary Clinton and her sole rival for the Democratic presidential nomination, Vermont Senator Bernie Sanders, split two state nominating contests Tuesday, leaving her closer to clinching the nomination in three weeks.

Clinton edged Sanders in the coal-producing state of Kentucky by about 2,000 votes. It was a margin close enough that election officials said they would not yet declare an official winner, but Clinton claimed the victory, her first in May. Meanwhile, Sanders defeated her in the Pacific coastal state of Oregon.

With the outcome in the two states, Clinton, seeking to become the country's first female president, could clinch the nomination June 7, when six states vote. Democrats would then formally declare her the nominee at their national convention in July.

How delegates are awarded

Democrats award delegates to the national convention proportionally, based on the outcome of state-by-state voting. Sanders gained just four on her Tuesday. Overall, Clinton has 2,291 delegates of the 2,383 needed to claim the nomination to his 1,528.

Sanders, a self-described democratic socialist who has attacked Clinton for her past support of U.S. trade deals and connections with Wall Street leaders, has acknowledged that he has only a narrow path to overtake her and claim the nomination. But he has vowed to stay in the race through the remaining state contests.

"Let me be as clear as I can be... We are in 'til the last ballot is cast," Sanders told a rally in California, the biggest state yet to vote in the lengthy campaign.

Going forward, Sanders would need to win about 85 percent of the remaining delegates to the national convention in order to surpass Clinton. He has won only one state by that margin so far, and that was in Vermont, his home state.

Sanders' supporters so far have resisted any move toward backing Clinton. They engaged in violent outbursts at a party convention in Nevada last weekend when they felt they were short-changed in the number of national convention delegates that had been awarded to Sanders to represent the western state.

June primaries

The Democrats have contests on June 4 in the Virgin Islands and June 5 in Puerto Rico. There are not enough delegates at stake in those contests for Clinton to clinch the nomination before the June 7 voting.

The Democratic nominee will face Republican candidate Donald Trump in the November general election to pick the successor to President Barack Obama when he leaves office in January after eight years in the White House.

Trump easily won Oregon's Republican primary Tuesday, with his remaining challengers dropping out of the party's nominating contest in early May. He has yet to officially clinch the party's nomination but also is likely to claim it on June 7.