Legions of young voters, both white and Latino, have helped Bernie Sanders chip away at Hillary Clinton’s lead in California, a new Field Poll shows, giving him a realistic chance to win the state’s Democratic primary — a prospect that seemed inconceivable just six months ago .

But even though Sanders is viewed more favorably than Clinton across the state, he could have trouble prevailing in the June 7 primary because some of his strongest support lies with groups who are less certain to turn out on Election Day.

“The segments of the voting population for Sanders are clearly there,” Field Poll Director Mark DiCamillo said. The big question, he added, is whether Sanders can mobilize his base of 20-somethings and independents to vote en masse.

Clinton is the top choice of 47 percent of likely voters, while Sanders is the first pick of 41 percent, according to the poll conducted March 24 through Monday. Sanders trailed Clinton by 11 percentage points in a January Field Poll and by a staggering 57 points last May.

The tightening race in California comes at a pivotal moment for Sanders, who trails Clinton by more than 200 pledged delegates and is running out of time to close the gap.

Analysts say he needs to win big in upcoming primaries in New York and several other northeastern states this month to make California a meaningful contest.

But polls show Clinton leading in New York, Pennsylvania and Maryland. And Sanders, who grew up in Brooklyn, has faced a nasty fight in his native state, where he has come under fire for his fuzzy plan to regulate Wall Street and traded barbs with Clinton about each other’s qualifications to lead the country.

Friday’s Field Poll underscores how difficult it will be for Sanders to surpass Clinton in the delegate count, said Jack Pitney, a professor of politics at Claremont McKenna College.

“The good news is that he’s made up ground,” Pitney said. “The bad news is that he’s still losing, and from the delegate math, he needs a solid victory in California and not just a psychological triumph.”

Measuring Sanders’ likely support in California is tricky, DiCamillo said, because an unusually high number of people who have never voted said that they will definitely vote for him.

“You have to go with their testimony,” DiCamillo said of Sanders supporters. “It looks like there will be a significant segment of people never voting before voting in this primary.”

Among first-time voters, Sanders led Clinton by 21 percentage points, the poll found.

Sanders also remains the overwhelming choice of the electorate’s least reliable voters: young people. The poll found him romping Clinton — 77 percent to 17 percent — among 18- to 29-year-olds. He also has a 25-point lead among voters in their 30s. But Clinton has strong majorities among voters 40 and older.

It’s the sharpest generational divide DiCamillo has seen since the 1960s, when young Democrats flocked to Eugene McCarthy and Robert F. Kennedy.

The age gap appears to have helped Sanders reduce Clinton’s lead from 18 points to just 7 among Latinos, a group that exit polls showed going 2-1 for her in Texas. Sanders led Clinton with 69 percent of Latinos and 62 percent of whites under the age of 40, the Field Poll found.

“The Clinton people were probably assuming that the Latino constituency would be one of her stronger segments,” DiCamillo said. “It’s not proving to be the case.”

Connie Moreno, a 33-year-old nursing student from Emeryville said she and her sister are trying to persuade their Mexican immigrant parents to vote for Sanders.

“I like the fact that he is willing to stand up against Wall Street and big banks,” she said. “And he isn’t taking money from lobbyists.”

The age gap came as no surprise to Linda Carroll, a 75-year-old tutor and Clinton supporter from San Jose whose students are overwhelmingly pro-Sanders. “If you promise someone that age group a free college education, of course they are going to be for you,” she said. “I’m more leery of the too-good-to-be-true people now, and I’m afraid Bernie might be too good to be true.”

Louis DeSipio, a Latino politics expert and director of the UC Irvine Center for the Study of Democracy, questioned whether Sanders should expect such a strong share of the Latino vote. “My suspicion is that we’ll see more of the older voters turning out, and Clinton will have an advantage,” he said.

Voters were also divided strongly by gender and party affiliation. Sanders led men by 8 percentage points, while Clinton held a commanding 17-point lead among women. Clinton led registered Democrats 50 percent to 39 percent; Sanders had a 10-point lead among independent voters, who are allowed to cast ballots in the primary.

Clinton led Sanders in every region of the state, though that is less important in the Democratic primary where delegates are awarded based on proportion of the statewide vote.

Both candidates are popular among Democrats, although Sanders supporters were nearly evenly split on Clinton. Among all voters, Sanders was viewed favorably by 55 percent of the electorate and unforably by 35 percent. Clinton’s ratings were decidedly more mixed. She was viewed favorably by 47 percent of voters and unfavorably by 48 percent.

The poll of 584 likely voters in the Democratic primary had a margin of error of plus or minus 4 percentage points.