Although Democrats won contentious races all across New York, losses in the Bronx and throughout Long Island gave Republicans hope.The last time voters in the Bronx were represented by a Republican on the City Council, Mayor Ed Koch was still asking voters “How’m I doin’,” Ronald Reagan was president and hip-hop music was mostly a local phenomenon.The idea that voters in the Bronx, one of the most deeply Democratic counties in the country, might send a Republican representative to the City Council would be nothing less than a “national embarrassment,” Representative Ritchie Torres said at a recent rally for the Democratic incumbent, Marjorie Velázquez.On Wednesday, that political ignominy came to fruition.With less than a thousand votes to spare, Kristy Marmorato, a conservative Republican candidate, was declared the winner by The Associated Press of the tightest City Council contest in the city, roughly 15 hours after the polls had closed.Ms. Marmorato had sparred with Ms. Velázquez about crime and her support of a rezoning that would bring affordable housing to the neighborhood in District 13 in the northeast Bronx. The area had shown signs of tipping to the right: In 2021, the Republican candidate for mayor, Curtis Sliwa, won more votes in the district than the Democrat, Eric Adams.Sensing a rare opportunity to flip a seat, the Bronx Republican Party went all in on the contest. The party sent 20,000 text messages to their base; made 40,000 robocalls in English, Albanian and Arabic; and made 10,000 live calls.“We threw everything and the kitchen sink at her,” said Michael Rendino, the chairman of the Bronx Republican Party who is also Ms. Marmorato’s brother. “It’s a wake up call to the Democratic Party.”Ms. Velázquez’s defeat still sends chills through the city’s Democratic establishment and gives hope to Republicans. Both parties are closely watching a smattering of off-year suburban contests across New York as bellwethers for 2024, when a half dozen key congressional races in the state could tip the balance of power in the House of Representatives.But for the most part, the potential rightward shift driven by changing ethnic demographics did not materialize in New York City, where all 51 City Council seats were up for re-election because of a once-in-a-decade redistricting process.In southern Brooklyn, Justin Brannan, the chairman of the finance committee and one of the most powerful members of the Council, scored a resounding victory against Ari Kagan, a Democrat-turned-Republican who quickly adopted his party’s views on issues like crime and abortion.Councilman Justin Brannan, center right, repelled a challenge from a fellow Council member, Ari Kagan, in a heated contest in southern Brooklyn.Paul Frangipane for The New York TimesIn a neighboring district, Susan Zhuang, a moderate Democrat, defeated Ying Tan, a Republican, in a district created to recognize the growth of the city’s Asian American population.The story was different on Long Island, where Republicans routed Democrats. Their dominance harkened back to the 1970s, when its suburban towns were a Republican stronghold, and suggested that concerns about crime, the cost of living and the state’s unfolding migrant crisis might be doing long-term damage to Democrats’ image in an otherwise hospitable state, where abortion rights are generally seen as safe.After Ed Romaine’s 15-point victory in the race for Suffolk County executive, Republicans have now flipped nearly every major office on Long Island since 2020. They also notched key victories in Long Beach and North Hempstead in Nassau County, traditionally Democratic areas included in the must-win districts of Republican Representatives Anthony D’Esposito and George Santos.The results left Democrats, who have lost three straight election cycles in the area, in a near panic.“The conventional wisdom is that the road to a Democratic majority of the House runs through New York,” said Representative Steve Israel, a former New York congressman who once ran Democrats’ campaign arm. “But there’s nothing but yellow lights blinking for Democrats, especially on Long Island, suggesting they are not getting the traction they need.”He said he had seen a “perception about crime and disorder and lawlessness that is hitting the anxieties of suburban voters,” with little sign of abating.However, the party notched much stronger performances north of New York City, where voters in the suburban towns that hug the Hudson River and in the state’s western reaches behaved much more like their counterparts in Virginia or Ohio.Democrats won key local races in Westchester and Rockland Counties, where Representative Mike Lawler, a Republican, faces one of the toughest re-election fights in the country next year. They appeared to be on track to win a trio of competitive district attorney contests in Ulster, Dutchess and Columbia Counties, a hotly contested territory where Representatives Pat Ryan, a Democrat, and Marc Molinaro, a Republican, will be defending key swing seats next year.And in Erie County, which includes Buffalo and its suburbs, Mark Poloncarz won a record fourth term as county executive. Republicans had pummeled Mr. Poloncarz over his handling of the state’s migrant crisis, but voters paid little mind, handing the Democrat a nearly 20-point victory.Jason Weingartner, the executive director of the state Republican Party, conceded upstate counties had lessons to learn from Long Island, particularly convincing voters to go to the polls early.Ms. Velázquez’s support for more affordable housing in the district displeased some voters.Anna Watts for The New York TimesEven though Ms. Velázquez won the June Democratic primary by almost 50 percentage points, the fault lines in that election showed that she was vulnerable on both crime and her decision to support the rezoning of Bruckner Boulevard to bring affordable housing to the neighborhood, Mr. Rendino said. Ms. Velázquez had opposed the project for months before changing her mind.Ms. Velázquez was elected as a progressive in 2021 but soon joined more than a dozen other Democrats in leaving the Progressive Caucus after they were asked to sign a statement of principles that called for “the size and scope” of the New York Police Department to be reduced. During the Democratic primary, Ms. Velázquez emphasized that she was a moderate.“I’ve heard that you’re socialist because you’re like A.O.C., and it’s like, no, I’m not,” Ms. Velázquez said in June, referring to Representative Alexandria Ocasio-Cortez, a democratic socialist.Ms. Marmorato, an X-ray technician and a married mother of an elementary aged daughter, has said that she was driven to run for office because she opposed plans to build mid-rise housing in an area of mostly single-family homes as part of the Bruckner rezoning and a proposal for supportive housing for people released from prison at a former Jacobi Medical Center building near her home.Speaking on NY1, she said that people wanted change. She called for more police officers.“They feel like there’s no more local control in our community,” she said. “They don’t have a say in what’s going on in their neighborhood and they’re just fed up with it.”Neither Ms. Velázquez nor her campaign responded to multiple requests to comment on Wednesday. Camille Rivera, a Democratic political consultant at New Deal Strategies, said the concerns raised about the Bruckner rezoning relied on “coded language” and racial fear mongering. Joseph Savino Jr. was the last Republican member of the City Council from the Bronx. He served as Councilman at Large from 1977 to 1983 before the position was abolished. In 1985 he was convicted of illegally possessing a machine gun and then pleaded guilty to tax evasion for failing to report $300,000 in income.Jamaal Bailey, a state senator who is the chairman of the Bronx Democratic Party, called Ms. Velázquez’s loss a local issue that would have little bearing on next year.“Taking a stand to make sure that more people have a place to live is a principled stance,” Mr. Bailey said, “and one that I believe that she’s proud of and one that we should be proud of as Democrats, especially in a housing crisis.”On Wednesday morning, Mr. Torres, one of Ms. Velázquez’s closest allies, described his “national embarrassment” remark as hyperbole meant to motivate supporters before an important election.“All politics is local, and nowhere are those words more true than in the East Bronx, where the racial and class politics of a rezoning can be treacherous,” Mr. Torres said. “A perfect storm put the seat in Republican hands.” More