Lawmakers agreed to a one-year extension of mayoral control of New York City schools Friday night, a short-term deal that represents a swipe at Mayor Bill de Blasio and sets up another year of political games between the mayor and state lawmakers.

As expected, the agreement avoids a total lapse in mayoral control, which would have caused procedural headaches for the city. But it represents a defeat for the mayor, who has now twice been unsuccessful at winning support in Albany for a longer-term deal.

In recent days, the Senate and Assembly had been locked in a stalemate on the issue. By Thursday evening, it was clear that Senate Majority Leader John Flanagan — de Blasio’s chief antagonist over mayoral control — had won out.

“While one-year extensions are no way to treat our children, families or educators,” de Blasio said in a statement after the deal’s announcement, “this action is a crucial acknowledgment by State lawmakers that the education progress we have made in New York City could not have happened without our accountable control of the school system.”

The deal includes provisions that require the release of more detailed budget information about New York City schools, according to information sent out by Gov. Andrew Cuomo’s office. Senators added that measure as part of a last-minute deal that State Education Commissioner MaryEllen Elia called troubling on Friday.

“We believe that a one-year extension of mayoral control with reforms that require school-by school budget data to promote greater fiscal transparency is in the best interest of students and their parents,” Flanagan said in a statement. (It was not immediately clear whether the bill will require information about individual schools or just the city’s community school districts.)

Lawmakers also agreed to give districts until the end of the year to negotiate the details of new evaluation systems for teachers and principals. according to Assembly spokesman Michael Whyland. Districts, including New York City, have been facing a Sept. 1 deadline to develop systems that complied with an unpopular 2015 law.

The deal also will allow charter schools to more easily switch between authorizers. That could mean the city’s education department, which oversees a number of charter schools but no longer accepts oversight of new schools, could see some of those schools depart for the State University of New York or the state’s education department.

That provision would only apply to “high-performing charter schools in good standing,” according to the governor’s office.

The deal avoids a number of provisions that would have been even more difficult for de Blasio to stomach.

It does not include an “education inspector,” part of an earlier Senate bill that would have given a governor-appointed watchdog the power to veto decisions made by the city’s Panel for Educational Policy, according to the details released Friday evening.

It also does not include a package of education tax credits that would benefit private schools.

Mayoral control was the most significant aspect of the deal, though, which lawmakers were expected to vote on Friday night. The issue has long been part of a larger political struggle between de Blasio and state lawmakers.

De Blasio attempted to upset Republican majority power in 2014, and has often feuded with Governor Andrew Cuomo.

This year, the mayor traveled to Albany for a four-hour long hearing, which Flanagan dismissed as displaying de Blasio’s “disturbing lack of personal knowledge about city schools.” De Blasio then skipped the second Senate hearing, setting off an avalanche of criticism from lawmakers annoyed by the mayor’s no-show.

A decision to extend mayoral control means the back-and-forth between de Blasio and state lawmakers will cement itself as an annual affair.

End-of-session discussions were also consumed by political jockeying. The Senate introduced two bills, both of which contained “poison pills” for either de Blasio or Assemblymembers, including the education inspector and a package of education tax credits. On Friday, senators threw in the measure to force schools to release more information about their budgets, complicating negotiations.

Meanwhile, the Assembly and the governor have been pushing for a long-term mayoral control extension since the beginning of the session.

Former Mayor Michael Bloomberg first won control of the city’s schools in 2002, and was granted seven years.

A number of prominent business leaders have stood with de Blasio on the issue, saying that fighting over control of the schools creates unnecessary instability.