For Mayor Bill de Blasio, it was a bare-knuckle political fight, complete with arm-twisting appeals to lawmakers and labor negotiations lasting late into the night.

By Monday morning, City Hall had a deal — although not for more affordable housing, higher wages or any of this liberal mayor’s top priorities.

This one was about the horses.

Two years after he embraced the polarizing cause of ending the Midtown horse-carriage trade, a request of some of his most generous campaign supporters, Mr. de Blasio is set to reduce the size of the industry and confine its horses to Central Park.

The agreement, which must be approved by the City Council, ensures that Mr. de Blasio’s legacy does not include eliminating a Victorian-era institution still broadly popular with the public. But the easing of one mayoral headache could be the start of many more, as parks advocates, carriage drivers and even some animal-rights supporters expressed concerns.