The New York state legislature is nearing the completion of a landmark session that has produced some of the nation’s most far-reaching liberal policies, demonstrating the strength of the left wing after the Democratic Party gained full control of the state government for the first time in more than a decade.

Gov. Andrew M. Cuomo (D) and Democratic lawmakers are celebrating what some liberals have called “historic” legislative wins, including passage of bills that nearly eliminate carbon emissions, codify the right to an abortion, end cash bail for many criminal defendants, and implement new protections and opportunities for undocumented immigrants, gay and lesbian Americans, and farmworkers.

New York is a heavily Democratic state where registered Democrats outnumber Republicans by nearly 3 to 1; however, the speed at which the state’s new Democratically controlled state government has enacted a liberal agenda shows how the party is shifting.

But with the session scheduled to end as soon as Wednesday night, some senior party leaders have expressed concerns that the party has gone too far and risks a backlash from voters outside of New York City. During the six-month session, ideological divisions between urban liberals and moderate Democrats from suburban and rural communities challenged some efforts to move the left-wing agenda forward. The differences caused some key legislative efforts to stall, including recreational marijuana legalization, which is now unlikely to come up for a vote this year.

Even some liberal factions have split on certain issues, namely over a bill to legalize paid surrogacy, with LGBT advocates supporting it while some feminist groups worry it would victimize women.

The aggressive Democratic agenda comes after the party picked up eight seats to win control of the New York state Senate last year, including flipping six seats on historically Republican Long Island. Except for relatively brief periods of time, Republicans had until this year maintained a majority in the New York Senate for more than a century.

“This was a test for Democrats running the government . . . and helps us see what a successful left-center Democratic effort might produce nationally,” said Gerald Benjamin, executive director of the Benjamin Center at SUNY New Paltz. “But what it doesn’t help us see is whether such an appeal would win” nationally.

On Wednesday, in a key victory for environmental activists, New York lawmakers approved one of the nation’s most ambitious plans to combat climate change. Under the bill, which Cuomo is expected to quickly sign into law, the nation’s third-largest economy plans to achieve an 85 percent reduction in greenhouse gas emission by 2050, including eliminating carbon emissions in the electricity sector. The bill would require New York to construct or purchase vast supplies of wind, solar and hydropower.

Melissa DeRosa, Cuomo’s secretary and one of his top political advisers, said the New York Democratic leaders are responding to President Trump’s policies and offering a potential blueprint for the party’s national agenda heading into the 2020 election.

“When Trump became president, the governor set out to not only continue to accomplish what we thought were big, nation-leading ideas, but what he has continued to say is there is an alternative to Trump’s America, and that is here in New York,” DeRosa said.

But other liberal priorities fell victim to divides in the party. Several moderate Democratic senators from suburban and rural districts opposed the recreational marijuana legislation, citing opposition from parent groups. Democrats were also divided over how proceeds from marijuana sales would be spent.

“My constituents have many concerns about legalization,” said state Sen. Pete Harckham, a Democrat who represents the lower Hudson Valley.

Jay S. Jacobs, chairman of both the New York State and Nassau County Democratic Party, said he worries that Democratic lawmakers passed “so many bills” favored by the left it would cost the party votes in the suburbs next year, when all New York assembly members and senators are up for reelection.

There was strong opposition on Long Island, Jacobs noted, to a bill Cuomo recently signed that allows undocumented immigrants to receive driver’s licenses. The Catholic Church has been a vocal critic of New York’s decision this year to codify Roe vs. Wade into state law, while many commuters object to the legislature granting New York City the authority to toll entry points into Manhattan, Jacobs added.

“Each one of those things have an angry constituency associated with it,” Jacobs said. “And when you add it up, layer upon layer, suddenly you don’t have a majority voting for you.””

One of the most controversial flash points within the party is the legislature’s decision this year to eliminate cash bail for defendants, except when someone is accused of a major violent crime, sexual assault or domestic violence, or is charged under the state’s drug kingpin statute.

The legislation was a priority for social and racial justice advocates but is being condemned by law enforcement and some Democratic leaders.

P. David Soares, a Democrat and the district attorney for Albany County, said the bail reform legislation is “going so far to the left” that it is “setting the conditions” for a GOP resurgence in New York.

Homeowners, he said, do not want see repeat burglary suspects quickly released from jail. He also said judges will also be forced to release most drug dealers before police even finish investigating their alleged crimes.

“How is a person with five kilos of fentanyl and dealing in vulnerable communities, and released back into the community the same day, benefiting that community?” asked Soares, president of the District Attorneys Association of the State of New York. “You don’t fix inequalities by passing legislation that promotes disorder and instability in those communities.”

Scott Roberts, senior director of criminal justice campaigns for Color of Change, which pushed for the bail reform legislation, countered that Soares is engaged in the “really old-school law-and-order” tactic of “fearmongering.”

“It’s a really tired approach to the justice system, and we are going to be fighting against any efforts to pull back from what we won so far,” he said.

Although some liberal activists appear satisfied with Cuomo this year, the governor and the more moderate leadership of the New York Senate did temper some of the far left’s agenda.

Cuomo, for example, resisted a proposal for a single-payer health-care law in New York, which would have been funded with a tax hike on the wealthy.

Lawmakers also struck a compromise on a bill to extend overtime pay to state farmworkers.

Political analysts say the divisions in New York offer lessons both for Democrats in Washington and in statehouses throughout the nation as Democrats try to expand their influence in state legislatures, including efforts this year to flip control of the Virginia General Assembly.

James Battista, an associate professor of political science at the University at Buffalo, said “angry liberals” are determined to use states as laboratories that move the agenda in “their direction.” But, Battista said, outside of the Northeast and West Coast, he expects moderates within the party will ultimately prevail when it comes to major policy decisions.

“There are chunks of New York lawmakers’ agenda, such as opposition to Trump, that might sell well in other parts of the country but a lot of it is just long-term Democratic dreams,” said Battista. “If the Virginia legislature flips, it’s not like you are going to see [Democratic leaders] taking up the same issues as they are in New York.”

But in New York, liberal activists say this year’s legislative session was just a precursor to what’s to come.

State Sen. Julia Salazar, a newly elected self-described democratic socialist from Brooklyn, said state lawmakers want to prove “progressive change” in a state as large as New York will also lead to a cascading effect of “economic justice” and “civil rights” nationwide.

“In the past three years people have been polarized by President Trump and by an apparent resurgence of far-right sentiments,” said Salazar, who is leading the effort to decriminalize sex work. “I think that people want to reject that and . . . [it has] agitated them to take a position and to choose which side they’re on.”

Jane Gottlieb in Albany, N.Y., contributed to this report.