As one of the largest rallies of his presidential campaign drew to a close, Sen. Bernie Sanders (Vt.) offered his voters some unusual and unwanted advice.

They might lose.

“This is a tough race for us,” Sanders told thousands of supporters in Manhattan last week. “We have a system here in New York where independents can’t get involved in the Democratic primary, where young people who have not previously registered and want to register just can’t do it.”

Boos echoed through Washington Square Park, where plenty of voters had learned this the hard way. They had missed New York’s stringent deadline — in October — to switch party registration in order to cast a ballot in Tuesday’s Democratic primary. Now, the Sanders campaign is pre-

spinning a possible loss here by criticizing that rule.

The challenge of competing in a closed primary such as New York’s, where polls show Sanders trailing front-runner Hillary Clinton by double digits, could serve as a final blow to his campaign. The democratic socialist’s success has been bolstered by independent voters in states where they were permitted to vote. But the improbable odds of winning the nomination in a party Sanders doesn’t even belong to may finally be catching up to him.

The presidential campaign for Democratic candidate Bernie Sanders released this video, focusing on Sanders New York roots ahead of the state's April 19 primary. (Bernie Sanders)

Beyond the trove of delegates at stake Tuesday in New York, the issue has sparked an existential question about what the primary should be — a lowercase-d­ ­democratic festival for all voters, or a chance for loyal activists to pick a nominee.

To some, including Democratic National Committee Chairwoman Debbie Wasserman Schultz, independent voters distort the process when they’re allowed to barrel into the primaries.

“I’m speaking for myself — this is not something that the national party’s had a discussion on – but in my opinion the Democratic primary should be determined by Democratic voters,” Wasserman Schultz, a congresswoman from Florida, said after Clinton and Sanders debated in New York on Thursday.

But to Sanders and his supporters, New York has become a study in shame, a reason why the primaries should be opened.

“Probably a lot of those people out there in the crowd, hopefully a small number comparatively, are not even able to vote in this election because they didn’t change their registration to Demo­crat last October, when they haven’t even heard of Bernie Sanders,” the candidate’s wife, Jane, said on MSNBC this week. “Those kind of things seem silly. We’re bringing a lot more people into the party, and the party is shutting the door on them.”

Said Ben Jealous, a former president of the NAACP: “The test of who can most unify and strengthen the party is informed by who can attract independent voters in the primaries. There are a lot of people who left the party looking for an authentic progressive, and in Bernie Sanders they have found an authentic progressive.”

Sanders himself has strongly suggested that the candidate who can pull independents into the primary — in this case, himself — is de facto the better candidate for a general election.

Actor Danny DeVito pumped up the thousands of Sanders's supporters in Brooklyn's Prospect Park on April 17. "We feel the Bern!" Devito said in front of an estimated 28,000 people days before New York's primary. (Reuters)

“This may be a shock to the secretary, but there are a whole lot of independents in this country,” he said on the debate stage Thursday. “We are not going to win the White House just with Democratic votes.”

One thing is clear: Without independents in those other states, Sanders probably would’ve been sunk long ago.

In Michigan, where Sanders won his greatest upset, Clinton beat him by 18 points among self-identified Democrats, according to exit polls. In Oklahoma, one of the few states that Clinton won in 2008’s primary but lost this year, she beat Sanders by nine points with Democrats. In Wisconsin, Sanders won overall by 13 points; he split the Democratic vote with Clinton 50-50.

In each case, independents who felt like pulling a Democratic ballot were able to vote for Sanders. In New York, many of the people who crowded Sanders’s rallies — some lining up for hours, Bernie buttons on their winter coats — admitted that they had not understood that New York’s rules were different.

“Nobody told us that we had to re-register,” said Toni Lantz, 24, who waited three hours to see Sanders speak in Rochester. “I’ve been an independent since I was 18. I didn’t like the choices until now; I consider myself to be more in the middle.”

Some did check the rules but couldn’t bring themselves to become Democrats.

“The minute that he declared he was running, I was supporting him,” Isabel Madden, 68, said at the Washington Square Park rally. “But it was important for me to remain independent, so I’ve been going around, trying to convince people to vote for him.”

Madden pointed to a friend she’d brought to the park. “There’s my proxy,” she said.

It’s been a problem for Re­publican front-runner Donald Trump, too. Like Sanders, Trump has benefited enormously from “crossover” votes. But his attorney and oldest children admitted that they missed the registration deadline in New York.

As Sanders attempts to surge from behind in the overall delegate race, he has to contend with half a dozen more closed primaries. Delaware, Kentucky, New Jersey, New Mexico, Oregon and Pennsylvania all limit their contests to registered Democrats.

New York’s closed primary elicited a special effort from the Sanders campaign. While voters registered as independents, Greens, Republicans or members of the Working Families Party had to switch in October, voters who had never registered before could become Democrats by March 25.

The campaign made a push for those potential new voters, especially on college campuses. In just the 10 days between March 10 and 20, close to 41,000 new voters joined the rolls.

Still, the push came before some voters had tuned in, and before Sanders himself really campaigned in the state. “It’s hard to know exactly what it yielded,” said Robert Becker, the campaign’s deputy national field director.

This month, as more Sanders fans learned of the rules, some grew desperate. Fred Thiele, an independent member of the state legislature who caucuses with Democrats, started getting more and more calls about his legislation to open up the primary.

“This is YUUUUGGGGEEE!!!” Sanders supporter Teresa Ash Willis wrote on a pro-Sanders Facebook page, sharing a link to Thiele’s bill. “If someone can find out when they are voting on this legislation, we should set up an event to have the public go to the hearing in massive numbers!”

Again and again, Thiele had to share the sad news: The bill couldn’t be acted on by April 19.

“I feel disenfranchised, too,” he said. “It’s ironic that I can vote on a $155 billion state budget, but next Tuesday I can’t vote in the primary. Maybe by 2020 we can change the law. In the meantime, what I tell people is that my heart and my $27 are going to Bernie Sanders.”

And in the meantime, Sanders will keep holding rallies where some of the faithful will be unable to vote for him.

In Washington Square Park, at least one of those voters had good news. Nika Lomazzo, 21, had never registered to vote in New York. She planned to travel home to Rhode Island, where she belonged to no party, and take advantage of that state’s open primary on April 26.

“I’ve never wanted to get registered with a party,” Lomazzo said. “I always want to remain independent. I’m glad I can keep loyal to that and still vote for Bernie.”