The decision to keep the order, the statement added, was Mr. Trump’s. It uses stronger language than any Republican president has before in favor of equal legal protections for gay, lesbian, bisexual and transgender people, though that is not likely to quiet Mr. Trump’s critics on the left.

The move could also anger conservatives who had hoped a Republican president would end some socially liberal policies.

While Mr. Trump remains opposed to the right of same-sex couples to marry, he has been more open to it than many in his party. But there could be another political cost to his decision: On the eve of the announcement of his pick to fill the vacant seat on the Supreme Court, it could reopen the divisive debate over same-sex marriage and transgender rights, and subject his nominee to more scrutiny over his or her views on those issues.

The Obama order banned companies that do federal work from discriminating against gay, lesbian, bisexual and transgender employees. It was the first time the government explicitly protected federal workers from discrimination based on gender identity.

Leaving those protections, of course, does not preclude another executive order that would roll back gay rights in other areas. Mr. Trump could, for example, still enshrine a religious freedom provision in federal policy.