(Reuters) - A second federal judge on Tuesday blocked President Donald Trump from banning transgender people from serving in the U.S. military, ruling that the prohibition likely amounted to unconstitutional discrimination.

U.S. President Donald Trump speaks during the 70th National Thanksgiving turkey pardoning ceremony in the Rose Garden of the White House in Washington, U.S., November 21, 2017. REUTERS/Jim Bourg

U.S. District Judge Marvin Garbis in Baltimore ruled that the ban lacked justification and “cannot possibly constitute a legitimate governmental interest.” His ruling followed a similar one by a federal judge in Washington on Oct. 30.

Garbis, appointed to the federal bench by former Republican president George Bush in 1989, went further than the Washington judge by also blocking the government’s directive to stop funding sex-reassignment surgery while the case moves forward, as some of the plaintiffs would be impacted by the prohibition.

“We’re pleased that the courts have stepped in to ensure that trans service members are treated with the dignity and respect they deserve,” said Joshua Block, an attorney at the American Civil Liberties Union, which is representing plaintiffs who filed a lawsuit against the ban.

Trump announced in July he would ban transgender people from the military, citing concern over military focus and medical costs. The move would reverse former Democratic President Barack Obama’s policy of accepting them.

Several transgender service members filed the lawsuit in August alleging the ban violated their right under the U.S. Constitution to equal protection under the law.

Lead plaintiff Brock Stone, 34, has served in the U.S. Navy for 11 years and wants to remain for at least 20 years, according to court papers.

After his policy announcement on Twitter, Trump signed a memorandum in August directing the armed forces not to accept transgender people as recruits and stopped the use of government funds for sex-reassignment surgeries for active-duty personnel unless the process was already underway.

The memo called on Defense Secretary James Mattis to submit a plan by Feb. 21 on how to implement the changes, and the Pentagon has created a panel of senior officials for that purpose. In the meantime, the current policy of allowing transgender people to serve remained in place.

Garbis said the transgender ban was not driven by genuine concerns for military efficacy.

“The lack of any justification for the abrupt policy change, combined with the discriminatory impact to a group of our military service members who have served our country capably and honorably, cannot possibly constitute a legitimate governmental interest,” he wrote in his ruling.

The U.S. Department of Justice said it disagreed with the ruling and was evaluating its next steps.