A judge isn’t allowed to preside over the livery industry’s suit seeking to stop riders from hailing yellow cabs with their smartphones, according to court papers.

The decision came after the judge hinted in a pre-trial hearing that he would rule against the city.

It’s a major victory for City Hall, which had pushed the court to remove Manhattan Supreme Court Judge Arthur Engoron from the case. Court administrators granted that request Wednesday.

Engoron, a former yellow cabby, has ruled against several of Mayor Bloomberg’s high-profile initiatives in the past, including the creation of a special fleet of livery cabs that could accept street hails in the outer boroughs.

The city is appealing that ruling.

Judges are assigned to cases at random, unless it has to do with another case on their docket.

In the latest lawsuit, lawyers for the livery industry categorized their case as related to the previous outer-borough taxi case — and Engoron was assigned the lawsuit.

Engoron called the e-hail pilot program “illegal” in the initial hearing.

Randy Mastro, the lawyer for the livery drivers, said he will appeal Engoron’s removal.

“Why are they doing this besides blatant forum shopping?” said Mastro. “We’re going to win the case no matter who the judge is. But we’re going to fight what the city is doing because it’s so wrong and offensive.”