WASHINGTON — Defense Secretary Ashton B. Carter on Thursday removed one of the final barriers to military service by lifting the Pentagon’s ban on transgender people serving openly in the armed forces.

“Effective immediately, transgender Americans may serve openly,” Mr. Carter said. “They can no longer be discharged or otherwise separated from the military just for being transgender.”

The decision pushes forward a transformation of the military that Mr. Carter has accelerated in the last year with the opening of all combat roles to women and the appointment of the first openly gay Army secretary. He made his feelings on ending the transgender ban clear last year, when he called it outdated and ordered officials across the military to begin examining what would need to be done to lift it.

When Mr. Carter ordered that assessment, there were already thousands of transgender people in the military. But until Thursday, most had been forced into an existence shrouded in secrecy to avoid being discharged, a situation much like that faced by gay men, lesbians and bisexuals before the lifting of the “don’t ask, don’t tell” policy in 2011.