The city is having problems keeping some cell doors locked and shut on Rikers Island.

So now, the state is trying to shut down about half of one jail dedicated to adolescents, and they want it shut down Tuesday.

NY1 has learned this fight has now sparked a legal battle between the city and the state.

"We're filing a lawsuit today that seeks to stop the closure of a larger part of RNDC," New York City Corporation Counsel Zachary Carter said.

This all started last week. NY1 obtained a letter sent from a state commission which oversees jails and prisons. Sent to the city last week, it reads "security sensitive document." It details how doors at the adolescent jail, known as RNDC, could be pried open. It happened late-last month, when seven inmates got out of their cells. It's happened 24 times in the last two years.

The commission's answer: Shut down about half of the facility. It demanded the city do it by close of business Tuesday.

Speaking on his weekly interview on NY1 on Monday night, the mayor this is all political:

"For some reason, the governor thinks its sport to suggest that they'll close different pieces of Rikers Island, while we're actually doing the serious work of trying to take care of the inmates better, create more security, and get off of Rikers Island once and for all," de Blasio said.

The city's lawsuit called the state's move "arbitrary and capricious," and said the state inspection was a "perfunctory visit and wholly inadequate inspection."

City officials tell NY1 that this closure would be unsafe and disruptive. Young inmates go to school in the facility. Shutting part of it down would mean they would have to be bused twice a day, back-and-forth.

The federal monitor for Rikers Island also weighed in, saying the abrupt transfer of adolescents raised serious safety concerns.

City Hall officials tell us these locking mechanisms could be at other facilities on Rikers Island, which means this argument could get bigger.