Leaders in Albany were also celebrating the House of Representatives returning to Democratic hands.

“The people have spoken,” said Carl E. Heastie, the Bronx Democrat who serves as speaker of the Assembly. “They said that they are tired of the attacks on health care, attacks on women’s reproductive rights and they are tired of tax cuts for wealthy donors.”

In New York City, voters also approved three ballot questions that a commission created by Mayor Bill de Blasio said would enhance democracy: reducing maximum campaign contributions and increases public matching funds; creating a commission to civic and electoral participation; and placing an eight-year term limit on community board members.

The odds in New York are almost always against Republicans, as Democrats have more than a two-to-one advantage in voter registration. Mr. Molinaro seemingly had tried to woo some moderates by running a campaign that largely avoided social issues, though his past votes as a state assemblyman against same-sex marriage had been a potent source of attack for the Cuomo camp.

Mr. Molinaro, who was elected mayor of Tivoli, N.Y., at 19, had also been unable to completely shed the association with President Trump, who is very unpopular in his home state; although he did not vote for Mr. Trump in 2016, he said he could embrace some of his policies if they were helpful to New York.

Speaking to supporters in Poughkeepsie, Mr. Molinaro said he hoped that the state’s government would become more inclusive, a theme of his campaign. “I hope as a state we learn to do things differently,” he said.