Hillary Clinton soundly defeated Sen. Bernie Sanders in her adopted home state of New York on Tuesday, placing the Democratic nomination nearly within her grasp after a fiercely fought primary season that has turned increasingly nasty.

With 98.5 percent of precincts reporting, Clinton led Sanders by 57.9 percent to 42.1 percent, allowing her to claim a lopsided share of the state’s delegates and strengthening her argument that there is no plausible way for him to erase her commanding lead.

“There’s no place like home,” a grinning Clinton told supporters in Manhattan.

“The race for the Democratic nomination is in the home stretch, and victory is in sight,” she said to thunderous applause. And then she addressed Sanders supporters directly: “I believe that there is much more that unites us than divides us,” she said.

Both Clinton and Sanders have called New York a likely watershed in the unexpectedly long campaign, a crucial test of strength for both candidates offering a treasure trove of 247 delegates.

For Clinton, winning the large, diverse state buoys her campaign after a string of losses to her underdog rival. A Sanders victory here would have badly embarrassed her in the state she represented as senator for eight years — and would have lent credence to his now-fading argument that he can still catch up.

Clinton’s decisive victory is certain to increase questions about whether Sanders risks damaging the party’s chances in November if he continues to campaign as aggressively against Clinton.

Sanders has vowed to stay in the race through the July convention, and his ability to raise money online from his legions of loyal supporters should enable him to do that.

Before the New York results were announced, Sanders flew to his home town of Burlington, Vt., without the traveling press corps that usually accompanies him.

“Today we took Secretary Clinton on in her own state of New York and we lost,” Sanders told reporters in Vermont after landing. “There are five primaries next week. We think we’re going to do well.”

Sanders claimed to still have the momentum in the race and said, “We think we have a message that is resonating.”

Campaigning earlier at Pennsylvania State University, Sanders complained about New York’s closed primary system, in which only registered Democrats can participate in the Democratic vote. According to exit polling reported by CNN, that requirement played strongly to Clinton’s benefit. Fully 83 percent of Democratic primary voters said they typically consider themselves Democrats, 10 points higher than the average so far this year and trailing only Mississippi. Clinton won self-identified Democrats by a margin of 61 percent to 39 percent. Sanders won nearly three-quarters of self-identified independents, but they accounted for only 14 percent of the electorate, similar to 12 percent in 2008.

Sanders has won independents by 62 percent to 36 percent across previous contests this year in which exit polls were conducted, while Clinton has won self-identified Democrats by 64 percent to 35 percent.

Those victories — coupled with Sanders’s continued success in drawing large, enthusiastic crowds, as well as his extraordinary fundraising success — have sustained his long-shot candidacy and complicated Clinton’s argument that she is the better candidate to face the Republicans this fall.

Clinton is attempting to turn her attention toward a general-election contest against either Donald Trump, who won New York’s Republican primary Tuesday, or Sen. Ted Cruz (Tex.). She is the foil for both Republicans, with each arguing that he is the better candidate to defeat her in November.

Earlier Tuesday, Clinton sought to turn the comparison with Sanders to international affairs and national security, areas in which she says his credentials are thin and hers robust.

“And at a time when terrorists are plotting new attacks and countries like Russia, China and Iran are making aggressive moves, protecting America’s national security cannot be an afterthought,” she said.

“Our next president has to be just as passionate about defending our country as she is about fixing our economy.”

Preliminary exit-poll data suggested a large nonwhite turnout. Roughly 4 in 10 Democratic primary voters were nonwhite, up slightly from 30 percent in the state’s 2008 primary. Exit polling showed Clinton winning nonwhite voters by a 67 percent to 33 percent margin, just shy of her 70 percent to 29 percent edge across previous contests.

Clinton performs best with defenders of Wall Street. More than 6 in 10 New York Democratic voters said that Wall Street does more to hurt the economy than help, according to preliminary exit polling reported by CNN, and these voters favored Sanders over Clinton by a 12-point margin. Clinton won by more than 50 points among the roughly 3 in 10 voters who said Wall Street does more to help the economy.

Hundreds of upbeat Clinton supporters gathered in a ballroom in Midtown Manhattan for her victory party Tuesday. They danced to a live band and DJ as they waited for results to roll in. The band struck up the Queen rock classic “Another One Bites the Dust” as the networks called the state for Clinton.

Aaron Leth, 30, has been a Clinton fan since he was a 6-year-old in Nebraska sending letters to the then-first lady when her husband, former president Bill Clinton, was in office.

“She’s going to win. It’s her home territory; she knows it,” Leth said.

Leth said he expects the Democratic primary season to continue into June, and he said Sanders has every right to remain in the race: “The people are speaking.”

The run-up to the New York primary included some of the most ornery exchanges between Clinton and Sanders, with the two questioning each other’s judgment, preparation and qualifications for the presidency.

During a debate in Brooklyn, they repeatedly talked over each other, unable to mask their frustration with the other’s attacks and counterattacks.

One the eve of the primary, Sanders’s campaign accused Clinton of having violated election laws through the use of a joint fundraising committee with the Democratic National Committee — a charge Clinton’s campaign dismissed as “shameful.”

The next round of primaries is also likely to be challenging for Sanders: Four of the five states with contests scheduled for next Tuesday — Pennsylvania, Maryland, Connecticut and Delaware — are closed to independents as well. Of the April 26 states, only Rhode Island allows unaffiliated voters to participate.

Sanders drew some flak in New York for leaving the state just days before the primary to participate in a conference on income inequality at the Vatican.

Sanders said he would never have forgiven himself had he forgone the trip, which included a brief meeting with Pope Francis. Aides also noted that Sanders was absent from the state for less time than Clinton spent away from the state fundraising in California over the weekend.

In the days before and after the trip, Sanders drew large crowds to rallies in Manhattan, Queens and his native Brooklyn.

Throughout the New York campaign, Sanders played up his roots. He spoke in unusually personal terms about growing up in a family with financial struggles in a rent-controlled apartment.

In the closing days of the race, his campaign aired an ad comparing Sanders to Franklin Delano Roosevelt.

“Even when the deck is stacked, a New Yorker will find a way to break up big banks, create millions of jobs and rebuild America,” the narrator said over archival footage of the former president. “Some say it can’t be done again. But another native son of New York is ready: Bernie.”

Wagner reported from State College, Pa.; Gearan, from Washington. Scott Clement in Washington contributed to this report.