The MS-13 gangbanger who allegedly killed a rival on a crowded Queens elevated subway platform slipped under ICE’s radar and was free to kill — thanks to a judge’s lenient bail ruling and New York’s sanctuary-city policy.

On Dec. 11, Ramiro Gutierrez was arrested on felony conspiracy charg­es. When he was arraigned two days later, Queens prosecutors asked that he be held in lieu of $100,000 bail, according to court records obtained by The Post.

Instead, Judge Barry Schwartz set bail at just $2,500 — which Gutierrez promptly posted.

“It’s a disgrace. That guy should have been in jail,” a police source fumed.

“It shows you how the system’s all f–ked up. He got out for $2,500 and then he’s out doing this? There’s no justice for anyone.”

Because he was in jail for only two days, federal immigration officials did not have enough time to interview him and determine his immigration status, officials with Immigrations and Customs Enforcement told The Post.

The city’s Department of Correction knew he was here illegally but never told ICE, according to lawyers and the feds.

“Alienage and immigration status are noted for any person who is detained in jail — 100 percent no question about it,” Staten Island immigration lawyer Ray Fasano told The Post.

But “there was no access to get that information prior to his release in [December],” an ICE spokesperson told The Post.

That’s because it’s Mayor de Blasio’s policy to cooperate with the feds only when someone is convicted of one of 170 listed “violent and serious crimes.”

While the felony-conspiracy charge against Gutierrez was on the list, the city wouldn’t even flag him to ICE because he had not been convicted.

“The 170 list is about convictions, not indictments,” said mayoral spokesman Seth Stein.

Citing New York’s sanctuary city laws, the DOC said it cooperates with ICE only after an individual has been convicted of a serious crime.

ICE realized the El Salvadoran citizen was in the country illegally only on Tuesday, after he was arrested in the fatal shooting of Abel Mosso in broad daylight Sunday on a busy 7-train platform in Jackson Heights.

Video of the slaying shows frightened straphangers running for cover as Gutierrez allegedly fires off six shots.

ICE has since put a detainer request on him, which asks local law enforcement to give the agency a 48-hour heads-up before releasing deportable immigrants from custody.

Gutierrez’s defense lawyer got the low bail amount by claiming his client was a humble family man who worked construction jobs and could not afford the steep $100,000 bail demanded by prosecutors.

“He is married, he has two children: a 2-year-old and an 8-year-old daughter,” the lawyer, Scott Bookstein, said during the December arraignment.

Gutierrez managed to post the $2,500 cash bail the very same day as the arraignment, court rec­ords show.

Bookstein did not respond to a request for comment.

Additional reporting by Tina Moore and Rich ­Calder