WASHINGTON — President Trump is preparing to give the Defense Department formal authority to expel transgender people from the military in an upcoming order, barring the Pentagon from recruiting transgender troops and cutting off payment for sexual reassignment surgery and other medical treatments for those already serving.

A White House memo that is expected to be sent to the Pentagon in coming days gives Jim Mattis, the secretary of defense, six months to enforce the transgender ban that Mr. Trump announced abruptly last month in a series of tweets. The directive was confirmed Wednesday by a person familiar with its contents but who was not authorized to discuss its details and spoke on the condition of anonymity.

The authority has not yet been finalized. Once it is approved, it would allow Mr. Mattis to force out transgender service members by setting a legal standard of whether they would be able to deploy to war zones or for other lengthy military missions.