NEW YORK — City officials are close to a deal that would save Central Park’s horse-drawn carriages from a threatened ban.

When Mayor Bill de Blasio was sworn in two years ago, he pledged to end the popular carriage rides through the park right away, calling it inhumane to keep horses in loud, car-clogged Manhattan. But now his administration is negotiating with a carriage drivers’ union a compromise deal that would keep the horses trotting.

As many as two-thirds of the approximately 200 horses working in the park would be permanently retired. The remaining ones would get a new home, a stable built within Central Park, a City Hall official told The Associated Press.

The Central Park stalls, replacing four privately owned stables on Manhattan’s West Side, would have space for around 75 horses, although the official said that number could change.

The move to the park would address one complaint from animal welfare activists: That the horses were in danger every time they made their daily walks from their staging area at the south end of the park to the urban stables where they now sleep at night.

One location being discussed for the horses’ new home flanks Central Park’s 86th Street Transverse.

But Elizabeth Forel, of the Coalition to Ban Horse Drawn Carriages, remains “absolutely” opposed to any plan that does not ban carriage horses altogether. She also questioned whether it’s proper to house horses belonging to private businesses in the very public Central Park, which serves as a refuge for harried urban denizens.

“What right does Mayor Bill de Blasio have to take public land and build a stable for private use?” asked Forel.

Besides, she said, even in the park, often filled with crowds, the horses can “get spooked” and run rampant.