The ruling from the Supreme Court -- its first on a practice known as "maternity harassment" -- will likely be embraced by Japanese mothers who say they hit a glass ceiling at work once they become pregnant.
"Under the gender equality law for employment opportunities, it is illegal and invalid to discharge or treat disadvantageously a female worker due to her pregnancy and delivery (of a child), as well as due to her request for maternity leave or a lighter workload," the court said.
The case stems from an unnamed hospital physiotherapist who had asked to be moved to a section with a less-strenuous workload after she became pregnant.
She agreed to move into a position with lower seniority as part of the move, but she was kept at the lower post after she returned from maternity leave, which she said was not part of the agreement with her employer.
Also Read
The top court's ruling on Thursday means that the lower panel will have to look at the issue again and reconsider its decision.
The ruling comes amid growing calls at home and abroad for Japan to make better use of its highly-educated but underemployed women as a rapidly ageing population strains the public purse.
But the task is a daunting one in a country where sexist attitudes are still prevalent and men dominate politics and business.
Prime Minister Shinzo Abe has made raising the profile of women in the workforce a key part of his wider bid to revive the world's number-three economy, dubbed "Abenomics".