NEW YORK — Hillary Clinton took a major step toward securing the Democratic presidential nomination Tuesday night with a critical win in New York, leaving underdog Bernie Sanders to complain about the refs.

The Clinton victory — by a decisive double-digit margin — interrupted Sanders’ eight-contest winning streak and blocked a key opportunity for Sanders to eat into Clinton’s large pledged delegate lead.

“You’ve proved once again there’s no place like home,” Clinton told more than 2,500 supporters in Manhattan. Both candidates claimed roots in the state, and Clinton added that this victory was “personal” for her. “The race for the Democratic nomination is in the homestretch and victory is in sight.”

The Empire State holds the second largest cache of delegates on the entire map for Democrats, and was Sanders’ last best chance to knock Clinton off her trajectory toward victory.

Sanders long-shot presidential bid started as a protest campaign and it looks like it’s heading back to that territory now.

Facing major headwinds, including limited ballot access and Clinton’s eight years as a senator from New York, it would have taken a miracle for Sanders to pull out a victory Tuesday night. His miracle didn’t come, and now, with most delegates already awarded and only 17 contests left, Sanders’ window to close the still large deficit is disappearing.

As at 1 a.m. ET, NBC News' delegate count had Clinton with 1885 and Sanders at 1190.

The Democratic race took turn for the nasty in New York, where Clinton and Sanders fought over everything from the timing of a debate to whether the other candidate was “qualified” to be president.

The final days leading up to the primary were dominated by allegations lodged by the Sanders that Clinton’s team violated campaign finance law in a cahoots with the Democratic National Committee — a charge both parties deny. Sanders aides also raised questions about the New York primary itself, calling attention to reports of voting irregularities.

Despite the acrimony, Democrats seemed to find the contest positive.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

More than two-thirds of New York Democratic voters said the campaign energized the party, while only 27 percent worried it divided the base, according to NBC News exit polls.

And while Clinton allies say Sanders’ attacks will make it more difficult for her to win a general election, Democrats seem prepared to vote for her. Just 13 percent of New York primary voters said they wouldn’t support Clinton in November, while 85 percent said they would.

Clinton choose to celebrate with supporters at the Sheraton in Times Square, a hotel that has hosted many Clinton events over the years and is the annual home of the Clinton Global Initiative.

Backed by a pantheon of city and state Democratic officials, Clinton took the stage to ”Empire State of Mind” by Jay-Z and Alicia Keys, accompanied sustained applause. While Clinton took swipes at Sanders for dismissing her wins as coming mostly from the South, she also began what will be a long and arduous process to repair the breach.

“To all the people that supported Senator Sanders, I believe there is much more that unites us than divides us,” she said.

Sanders, meanwhile, was long gone.

After strolling around Times Square Tuesday morning, the Vermont Senator left New York for events at State College in Pennsylvania, the largest of five states that vote next Tuesday.

Then, just as polls were closing in New York, Sanders boarded a plane to fly home to Burlington, Vermont, leaving his entire press corps behind.

As for the race, Sanders shows no signs of going anywhere, despite Clinton’s call for unity. Sanders campaign manager Jeff Weaver pledged late Tuesday that the campaign would go all the way to the Democratic convention in July, instead of rallying behind Clinton. Weaver told MSNBC’s Steve Kornacki that the race will come down to super delegates, whom the Sanders’ camp will work to flip even after voting has finished on June 7. Weaver said he believes they will come around if they can be convinced Sanders is the stronger general election candidate. And on a hastily arranged conference call, Sanders told reporters in Burlington that he’s looking forward to upcoming contests in Pennsylvania, Maryland, Delaware, Connecticut, and Rhode Island.

Sanders and his supporters spent the final hours before the networks called the race raising questions about the process, with some supporters alleging their voters were suppressed. Sanders is the longest serving independent in Congress and much of his support comes from independent voters, but New York state does not allow them to participate in its party primaries.

Speaking on campus at Penn State, Sanders passionately condemned voter restrictions and called for major reforms in the state. His supporters made similar claims after his loss in Arizona, where they blamed long lines and the state’s closed primary.

For a candidate who has complained that the national media doesn’t pay enough attention to substantive issues, he spent much of the New York primary complaining about process: the debate, the closed primary, Clinton’s Victory Fund with the DNC.

“If you can believe this, in New York state today, about 27 percent of the eligible voters in that state are unable to participate in the Democratic or Republican primaries because they have chosen to list themselves as Independents. That’s wrong,” Sanders said. Independents tend to favor Sanders.

Sanders also complained that polls only opened at noon in less populated parts of the state, noting it makes it hard for working people to participate.

And he condemned the fact that tens of thousands of voters were allegedly purged from voting rolls in Brooklyn. New York City Mayor Bill de Blasio, who is supporting Clinton, called for an investigation and Comptroller Scott Stringer said he would conduct an audit.

“Despite the fact that the entire, virtually the entire New York political Democratic establishment is standing with [Clinton], you know what, we’re gonna do just fine tonight in New York,” Sanders said.

A Clinton aide suggested the voter purge actually cost them votes instead, since Clinton won the borough and the purges came from heavily diverse neighborhoods.

Demographically, New York looked like almost every other contest. Young people gave Sanders’s his biggest victories while Clinton earned huge margins from African-Americans. He did a bit better with Latinos, coming close to getting 40 percent of the bloc, but Sanders was unable to make much headway with black voters, whom Clinton won three-to-one.

Geographically, Sanders won almost the entire state north of New York City. He was counting on racking up small town victories Upstate, but there are not enough voters there and his margins were too small to even catch up to Clinton’s strength Downstate.

Going forward, Sanders will need to find a rationale to stay in the race, especially if he’s going to keep up his attacks on Clinton. With millions of die-hard supporters across the country fueling his revolution with small donations, that may be all the rationale he needs.