In a case that could have wide-ranging national significance for gay rights, a federal appeals court in New York ruled on Monday that a landmark civil rights law bars employers from discriminating against their workers based on sexual orientation.

The decision was a setback for the Justice Department, which under President Trump had unexpectedly interceded in a discrimination lawsuit filed by a sky-diving instructor. The department had argued that Title VII of the 1964 Civil Rights Act did not explicitly cover sexual-orientation discrimination in the workplace, a stance that put it at odds with another federal body, the Equal Employment Opportunity Commission.

In rejecting the Justice Department’s argument, the United States Court of Appeals for the Second Circuit became the second appeals court to rule recently that the Civil Rights Act, which outlaws bias in the workplace on the basis of “race, color, religion, sex or national origin,” should also be extended to include sexual orientation. A third appellate court in Atlanta has ruled differently.

While gay rights groups hailed the decision on Monday, the ruling could create a scenario in which the issue of gay rights at work will be decided by a Supreme Court that already bears Mr. Trump’s imprint, with his nomination of Justice Neil M. Gorsuch.