A series of blowups in closed-door negotiations this week turned into serious snags Friday and forced lawmakers to miss the midnight deadline to approve the state’s $162 billion budget, but leaders said they were getting close to agreement.

A stalemate earlier on Friday triggered 11th-hour gamesmanship to apply pressure for a compromise. The Republican-controlled State Senate adjourned just after 3 p.m., citing no progress, with some members heading for the highway to get out of town. Then came a threat from Gov. Andrew M. Cuomo to force through an “emergency” spending bill to keep government going, Democratic sources said.

Senate Majority Leader John Flanagan (R-East Northport) then called the Senate back to the Capitol for an 8 p.m. meeting, Republicans said. Cuomo didn’t immediately respond to a request for comment.

Flanagan emerged from a series of meetings and declared less than hour before the midnight deadline that talks were back on track and leaders are “very close.”

“We are still working,” Flanagan said, praising the governor. “If he baked the cake, we’re providing the icing and candles.”

The Senate and Assembly plan to work through the weekend to pass the budget, which is hung up primarily over two policy issues. One is a measure to divert 16- and 17-year-olds accused of crimes into youth and family courts rather than adult criminal courts. The other would lift the cap on allowing more charter schools, an issue strongly supported by Senate Republicans and just as strongly opposed by Assembly Democrats.

One Republican lawmaker said a realistic time frame for approval of the budget might have leaders “getting everything in order tomorrow,” meaning Saturday, and the rank-and-file “maybe voting on Sunday,” though the lengthy process could run into Monday.

The 2017-18 budget is now the third state budget in a row that is late. Gov. Andrew M. Cuomo’s first four budgets were on time.

The Senate’s Republican majority has for days pushed to lift the cap on charter schools and also to let a “freeze” on about $400 million in charter school funding lapse as scheduled. Advocates for traditional public schools argue that reduces their funding.

Assembly Democrats want to keep the cap on charters, noting that there are still dozens of available charters for private operators to seek to run the publicly funded schools.

“We don’t see any need to increase the number of charter schools,” Assembly Majority Leader Joseph Morelle (D-Rochester) said.

The other major snag is a proposal sought by Cuomo and Assembly Democrats to move 16- and 17-year-olds accused of nonviolent crimes out of criminal courts to give the youths another chance to their turn their lives around. The Senate’s Independent Democratic Conference has pushed hard for the measure, but Senate Republicans warn the measure could be soft on crime and make youths pawns of violent gangs.

State Sen. Patrick Gallivan (R-Buffalo) said the main dispute is identifying what are violent crimes that would still go to adult criminal court, rather than a youth court or Family Court.