WASHINGTON — Transgender troops who are currently in the United States military may remain in the ranks, the White House said late Friday, but the Pentagon could require them to serve according to their gender at birth.

The policy recommendation that President Trump approved flatly states that “transgender persons who require or have undergone gender transition are disqualified from military service.” But it also largely gives the Pentagon the ability to make exceptions where it sees fit.

The policy adopts recommendations that Mr. Trump received last month from Defense Secretary Jim Mattis. It comes after court rulings froze the president’s initial ban on transgender troops — issued in July — as potentially unconstitutional.

“In my professional judgment, these policies will place the Department of Defense in the strongest position to protect the American people, to fight and win America’s wars, and to ensure the survival and success of our service members around the world,” Mr. Mattis wrote in a summary of his recommendations to the president.