The Tokyo District Court ruled Monday that the capital's municipal government must pay a total of 537 million yen (USD 4.5 million) to 22 former high school teachers.
The group said the city refused to re-hire them under a scheme that extends employment past the retirement age, because they disobeyed orders to stand and sing the anthem at graduation ceremonies.
Some critics say Japan's anthem amounts to a call to sacrifice oneself for the emperor and celebrates militarism.
In 2012, the supreme court ruled that penalising teachers for not standing to sing the anthem was constitutional, but it warned administrators to exercise care in going beyond a reprimand.
Also Read
On Monday, district judge Toru Yoshida said the Tokyo government's refusal to re-hire the group was disproportionate to the offence.
"There needs to be careful consideration when penalising people because they behaved in a way based on their own beliefs," he said, according to public broadcaster NHK.
"Because of our punishment, other teachers have felt threatened to express their opinions to superiors, such as principals," he told AFP on Tuesday.
"You are told not to think for yourself but just do what you're told."
Last month, Abe told parliament that raising the national flag and standing to sing the anthem at school ceremonies should be done not only in elementary and secondary institutions, but also public universities.