Copyright The New York Times

Representative Mikie Sherrill, the Democratic candidate for governor of New Jersey, catapulted to victory on Tuesday on the strength of her opposition to President Trump after a hard-fought race against Jack Ciattarelli, a Republican whose energetic campaign could not outrun national politics in a liberal-leaning state. Ms. Sherrill, 53, a former Navy helicopter pilot and federal prosecutor, will become New Jersey’s 57th governor and its second female leader. She was leading Mr. Ciattarelli, a former state lawmaker running his third race for governor, by about 14 points 90 minutes after polls closed, according to a tally by The Associated Press. The race was largely defined by Mr. Trump, who made surprising inroads last November in New Jersey and who had endorsed Mr. Ciattarelli. But in a state where Democrats outnumber Republicans by roughly 850,000 voters, the alliance always carried risk. The dominant theme of Ms. Sherrill’s campaign was her opposition to Mr. Trump, who she has long maintained presents an existential threat to the country. Ms. Sherrill, much like Abigail Spanberger of Virginia, a Democrat who also won her race for governor, is a centrist. Both women ran middle-of-the-road campaigns that emphasized their moderate records in Congress and their national security backgrounds. Their strategies stood in stark contrast to Tuesday’s other momentous race, for mayor of New York City, where the populist fighter Zohran Mamdani enchanted younger, left-leaning Democratic voters, suggesting a party in the throes of an identity crisis. Ms. Sherrill will now have to at least coexist with the president, who has shown a willingness to punish his foes. That was an argument Mr. Trump raised in the final weeks of the campaign, in a telephone pep rally he held for Mr. Ciattarelli. “He’s got a friend in the White House,” the president said during the call, “where she certainly doesn’t.” Ms. Sherrill has pledged to freeze the state’s high electricity costs by declaring a state of emergency on her first day in office in January. She plans to get cellphones out of classrooms and hire more mental health counselors for schools. Using data gathered through a new “social media addiction observatory,” she has said, her administration will take on digital platforms that use algorithms to lure in children and teenagers. In the 2021 campaign, Mr. Ciattarelli lost by three points to Gov. Philip D. Murphy, a Democrat barred by term limits from running for re-election. He tried hard during this race to capitalize on the stunning gains Mr. Trump made in Black and Latino communities, campaigning aggressively in churches and at cultural events. Mr. Ciattarelli was known as a moderate in the State Assembly, and until this campaign he had kept Mr. Trump at arm’s length. But after the president’s stronger-than-expected showing last year in some of New Jersey’s most diverse communities, Mr. Ciattarelli pivoted, embracing the president and some of his policies, even giving Mr. Trump an “A” grade in the final debate. His platform was focused heavily on pocketbook issues like taxes and energy costs. But Mr. Ciattarelli also leaned into issues popular with the far-right flank of the party, including publicly funded school vouchers, opposition to transgender rights, vaccine skepticism and the deportation of migrants. On the stump and in ads, Ms. Sherrill’s campaign regularly reminded voters of Mr. Ciattarelli’s cozy relationship with Mr. Trump. Then, last month, the president said he was terminating funding for the construction of a $16 billion train tunnel considered vital to the country and to New Jersey’s 200,000 commuters, handing the Sherrill campaign an unexpected gift. “With less than 19 days until this election, the president’s punched him in the face like this. That’s pretty telling,” she said the next day, highlighting the ephemeral value of Mr. Ciattarelli’s partnership with a mercurial president. Discussion of the tunnel project, known as Gateway, became a refrain for Ms. Sherrill in the closing stretch of the race. It also gave her a way to change the subject from a controversy centered on why she had been barred from participating in her 1994 graduation ceremony at the U.S. Naval Academy. She has said that she could not participate because she had failed to “turn in” classmates caught up in a cheating scandal. But polls began to narrow as Mr. Ciattarelli publicly challenged that explanation and sought to undermine her credibility, denting a central pillar of her campaign: that nine years in the Navy had prepared her to lead the state. Only New Jersey and Virginia hold races for governor the year after a presidential contest, and the results are considered bellwethers heading into next year’s pivotal midterm elections, which will determine party control of Congress. In Virginia, Ms. Spanberger beat her Republican opponent, Lt. Gov. Winsome Earle-Sears; Ms. Spanberger will be the first woman to serve as governor of the state. Democrats do not hold a majority in either the House or the Senate, leaving them with few tools to try to block Mr. Trump’s efforts to expand executive power. They had looked to New Jersey’s and Virginia’s elections, and a ballot referendum in California, as a way to try to build momentum heading into the 2026 congressional races. New Jersey’s race was always seen as far more competitive. And Ms. Sherrill’s campaign had become a cause célèbre for Democrat-aligned national groups, which committed roughly $25 million to help her win. An array of prominent Democratic leaders also traveled to New Jersey to campaign with Ms. Sherrill in the final weeks of the race. On Saturday, an appearance by former President Barack Obama drew thousands of party faithful to a large gymnasium at a community college in Newark. He energized the crowd by warning, as Ms. Sherrill has, about the threat posed by Mr. Trump. “We’ve got a commander in chief who has fired decorated military officers because he thinks they might be more loyal to the Constitution than they are to him,” Mr. Obama said. “He’s deployed the National Guard in American cities and claimed to be stopping crime waves that don’t actually exist,” he added. “We’ve got masked ICE agents pulling up in unmarked vans and grabbing people off the streets.”