Bernie Sanders won Oregon's Democratic primary while falling barely short of another victory in Kentucky on Tuesday, prolonging his battle with Hillary Clinton despite his slim chance of securing the party's presidential nomination.
His victory in Oregon showcased his support with progressive voters skeptical of Clinton and eager for a more uncompromisingly liberal approach to government.
As the results were being tallied, Sanders was telling a crowd of thousands in Carson, Calif., that he plans to fight until the Democratic convention in July.
"We are in till the last ballot is cast," he said.
Clinton campaigned heavily in Kentucky in the final days before the primary to eke out a narrow victory in the state as she tries to keep her focus on a potential general election matchup with Donald Trump, the presumptive Republican nominee.
With nearly all precincts in Kentucky reporting, Clinton led Sanders by less than 2,000 votes out of more than 400,000 cast.
"We're always stronger united," Clinton said in a tweet as she declared victory.
In a Democratic contest that has become almost more about psychology than delegates, the Kentucky primary took on outsized importance as Clinton worked to avoid a double loss for the day. Both campaigns had expected Clinton to lose the night's other contest, in Oregon.
In Kentucky she lost heavily in the coal-dominated counties in the eastern part of the state that once were Democratic bastions but have largely abandoned the party in federal elections. But the Democratic front-runner made up the difference by winning the state's two largest cities, Lexington and Louisville.
With the results so close, Sanders' campaign did not rule out the possibility of calling for a recount.
"We will take a close look at the numbers and make a decision on Wednesday," said spokesman Michael Briggs.
As the votes were being counted, Sanders campaign manager Jeff Weaver said on CNN that the tight race in Kentucky showed there were still reservations about Clinton. She won the state handily during the 2008 primary.
"There are a lot of Democrats who are having second thoughts," Weaver said. "I don't think the voters are ready for this race to be over."
Clinton has a comfortable lead in the race for delegates to this summer's nominating convention and only needs to win a small fraction of the remaining vote to clinch the nomination.
But two losses after several other Sanders victories would be a black eye after what's become an increasingly raw contest pitting the Democratic establishment against a grass-roots insurgency with a strong sense of grievance.
Tensions overflowed in Nevada over the weekend, when Sanders supporters accused party leaders of unfairly awarding Clinton more delegates during the state convention. The state party rejected the charges -- Clinton, after all, had won the caucuses earlier this year -- but its leaders were bombarded with criticism, invective and even threats.
Sanders issued a statement Tuesday condemning harassment but blaming the party leadership for the fracas.
"The Democratic Party has a choice," he said. "It can open its doors and welcome into the party people who are prepared to fight for real economic and social change ... or the party can choose to maintain its status quo."
Although Sanders has only a slim chance of winning the nomination at this point, he has vowed to continue his campaign until the convention in Philadelphia in July.
Going into Tuesday's primaries, Clinton led Sanders among pledged delegates, 1,716 to 1,433. There were 55 up for grabs in Kentucky and 61 in Oregon. Clinton also has the loyalty of many more superdelegates, the elected officials and party leaders who can choose which candidate to support.
The gap has allowed Clinton and her allies to turn their attention, and their fundraising firepower, to Trump, the presumptive Republican nominee.
Priorities USA, a super PAC allied with Clinton, is spending $6 million to run two new television advertisements hitting Trump in Florida, Nevada, Ohio and Virginia. A statement from the organization called Trump "a dangerous and divisive con man who should never be president of the United States."
Sanders was widely expected to win Oregon, despite a recent poll showing him trailing there, but Clinton has made a heavy investment in time, and some money, in Kentucky in recent days.
While Clinton left Oregon off her travel itinerary, she held five events in two days in Kentucky, not to mention visits to churches and a diner.
She told the crowd at the diner that she would ask her husband, former President Bill Clinton, to help out on economic issues if she reaches the White House.
"I'll expect him to go to work ... to get incomes rising," she said.
Her final rally was at Transylvania University in Lexington, where she made her last pitch before beating then-Sen. Barack Obama in the state's primary in 2008.
Clinton even outspent Sanders on television advertising in Kentucky, dropping $178,000 compared with Sanders' $107,000, according to data from SMG Delta, which tracks campaign spending. In recent primaries, Clinton has generally allowed Sanders to dominate the airwaves, and she didn't spend any money in Oregon, where Sanders dropped $123,000.
Oregon has had a robust contingent of Sanders volunteers, and they've helped rally nationwide support for the candidate by using phone banks to target other states. Monte Jarvis, the campaign's state director, said it was important to redirect the focus to Oregon for the primary.
"They had all this time with a national picture in our mind," he said. "And we had to say, 'No, no, Oregon needs attention.' "
The Oregon poll released last week showed Clinton leading, 48% to 33%. Even with higher turnout among young and new voters, who are expected to favor Sanders, she still had a 7-point lead.
But a big registration effort by the Sanders campaign in April apparently helped make the difference. Volunteers helped sign up thousands of voters as Democrats so they could cast ballots in the state's closed primary.
Sanders has struggled in closed primaries, where only people registered as Democrats can vote for one of the party's candidates.
Jillian Schoene, the Oregon state director for Clinton's campaign, expects Sanders supporters to shift their allegiance to Clinton after the primary.
When volunteers make phone calls, voters often say, "I'm going to vote for Bernie in the primary but I'll vote for Hillary in November," Schoene said. "We are hearing a lot of that."
Referring to Trump's "divisive language," she said, "Democrats are going to unite against that."
MORE POLITICAL COVERAGE
11:21 p.m.: This story has been revised throughout for additional details and for clarity.
8:46 p.m.: This story was updated to report that Hillary Clinton apparently won the Kentucky primary and that Bernie Sanders had won Oregon.
6:30 p.m.: This story was updated with complete returns from Kentucky.
4:04 p.m.: This story was updated with early returns.