A district court ruled Wednesday in favor of two subway drivers who had sought compensation from the Osaka municipal government, claiming they received poor performance reviews for refusing to comply with internal regulations banning beards.

The Osaka District Court ordered the city to pay the men a total of 440,000 yen ($4,000), saying that setting a blanket ban on beards goes beyond the scope of service disciplines because wearing beards is a matter of "individual freedom."

The men had filed the suit in 2016, seeking 4.4 million yen and a recognition from the local government that workers were not obligated to shave beards.

Beards "cannot be taken on and off" and restricting them in service disciplines "will affect private lives," Presiding Judge Hiroyuki Naito said in the ruling.

He also said it was "illegal" that the drivers were given lower scores in their performance reviews and were told by their bosses in interviews that they would be punished for not abiding by the internal regulations.

The two drivers had worn beards for more than 10 years when the Osaka transportation bureau introduced grooming standards in 2012, under which male employees were prohibited from growing beards under a policy promoted by then Osaka Mayor Toru Hashimoto.

They did not follow the rules and were poorly assessed in their performance reviews in fiscal 2013 and 2014, according to the ruling.

The court recognized in the ruling that setting internal regulations urging employees to shave beards have been reasonable on the grounds that people wearing them are not necessarily broadly accepted "positively" in society.

But it noted that the regulations should have been used to seek "voluntary cooperation" on the issue, not as an "order."

The plaintiffs' suit has argued that wearing a beard is part of "individual freedom, similar to choosing clothes or hairstyles."

The city had defended its position by saying it had received complaints from citizens who found the beards distasteful. It did not force the drivers to shave them off but had only made a request, it said.

But one of the plaintiffs said in an earlier news conference he always took care to groom his beard and never received any complaints from passengers.

The Osaka subway is no longer operated by the city and there are no internal regulations banning beards. The two men, wearing beards, continue to work as drivers.

The local government said it will consider its next action after talking with Osaka Metro Co., the current operator of the subway system in the city and the vicinity.