Tony Perkins, the president of the Family Research Council, a group that advocates socially conservative and Christian causes, applauded Mr. Trump’s decision to bar transgender people from the military. The president, he said in a statement, should be praised for “rescuing our troops from the grip of the Obama years and restoring a sense of true pride to a military devastated by two terms of social engineering.”

For Mr. Trump, the issue of transgender service in the military affects a fraction of the population but may resonate with his core political supporters.

Anthony D. Romero, the executive director of the American Civil Liberties Union, said the ban and other moves were “the most cynical of dog-whistle politics” and an effort to “rile up the president’s base as this administration flounders on health care reform and the Russia investigation, and as its popularity ratings plummet.”

Legal specialists said the most important political fact about the friend-of-the-court brief was that it was filed at all. Normally, the Equal Employment Opportunity Commission, not the Justice Department, weighs in on discrimination cases involving private employers. Moreover, the court had asked only the employment commission, and not the Justice Department, for its opinion.

The commission said the Civil Rights Act’s ban on sex discrimination should be interpreted as including protections based on sexual orientation. But the Justice Department contradicted that, submitting its own brief declaring that courts should not extend that protection to gays and lesbians.

The brief was less of a reversal of any concrete position the federal government had taken during the Obama administration, than of its earlier trajectory. During the Obama era, when the Justice Department was called upon to defend the federal government against employment lawsuits, it also sometimes argued that sexual orientation alone was not protected by the Civil Rights Act.