A US judge ruling on President Trump’s trans military ban has likened the policy to the discrimination of black people in the armed forces.

Marsha J Pechman, a federal judge in Seattle, is hearing a challenge aimed at blocking the effort to exclude trans people from serving.

This week, in comments reported by Bloomberg, she compared the policy to the historical exclusion of blacks from the military and the ban on mixed units. She said it had been an “error” that the courts signed off on those past decisions.

The judge is being urged to rule that Trump’s controversial policy is unconstitutional.

American LGBT advocates the Human Rights Campaign and the state of Washington argue the government has failed to demonstrate that allowing trans people to serve would damage military readiness or unit cohesion.

Last week, the White House announced it was seeking to formally ban such individuals “except under certain limited circumstances”.

Related: A second openly transgender person has signed up to the US military

It came after Trump stated last summer that he would ban trans people from serving in the military “in any capacity”.

At the time, the president said that the armed forces “cannot be burdened with the tremendous medical costs and disruption”.

However, his claims have been roundly criticised, including in a letter signed by 56 retired admirals and generals who said the discriminatory policy would harm morale and downgrade military readiness.

Critics have also argued it will force trans members to hide their identities while depriving the military of talent as well as reinforcing harmful and inaccurate stereotypes.

Related: Britain’s highest-ranking transgender soldier marries actor in dreamy Disney wedding

Judge Pechman is expected to make her decision next month, after receiving more information on the proposed ban from the government.

Trump’s policy would overturn a decision made by his predecessor, Barack Obama, in 2016 which lifted a ban on trans people serving openly in the military.