WASHINGTON—President Donald Trump partially reversed himself Friday and decided to allow many of the currently serving transgender people to remain in the armed forces, but he banned the future recruitment of most individuals who are considered transgender.

The White House said it has endorsed the recommendations of Defense Secretary Jim Mattis to permit some transgender service members to remain, in essence rescinding Mr. Trump’s own tweets and memos last summer in which he said he would no longer allow transgender individuals...