BERLIN, Germany — A German court has ruled that certain police are allowed to carry out ID checks on the basis of skin color.

The administrative court of Koblenz, in western Germany, today dismissed a complaint by a black German man who was asked to show his papers while travelling by train, the Deutsche Press Agentur reported.

More from GlobalPost: NYPD defends record number of stop-and-frisk searches

He refused and was taken to a police station to be searched. The two federal police officers involved accused him of abusing them and filed a complaint, which led to a court hearing in which one of the officers said he checked the ID of train passengers he judged to be foreign – a judgment that he based, in part, on skin color.

The man then decided to sue the police for illegal conduct.

However, judges ruled that skin color was reasonable grounds on which to carry out ID checks, since the train route in question is often used by illegal immigrants to enter Germany. Since police cannot check every passenger's papers, they must select which people to ID based on their "border policing experience," the judgment said.

The officers are therefore allowed to make their choice "according to external appearance" and without concrete grounds for suspicion, Agence France Presse reported.

"If this is true, it is essentially illegal," Tahir Della of the Black People in Germany Initiative rights group told The Local. "The authorities have always said the police do not do racial profiling."

The ruling may be appealed in a higher state court, according to German network RTL.

More from GlobalPost: Germany's war on solar power