The surprise announcement by Trump, who as a presidential candidate last year vowed to fight for lesbians, gays, bisexuals and transgender people, came in a series of morning Twitter posts. It drew condemnation from rights groups and some lawmakers in both parties as discrimination with purely political motives but was praised by conservative activists and some Republicans.
Trump spokeswoman Sarah Sanders said the administration has not yet decided whether transgender service members already in the military would be immediately thrown out, saying the White House and Pentagon would have to work that out.
The decision reverses Democratic former President Barack Obama's policy and halts years of efforts to eliminate barriers to military service based on sexual orientation or gender identity.
"After consultation with my Generals and military experts, please be advised that the United States Government will not accept or allow transgender individuals to serve in any capacity in the U.S. Military," Trump tweeted, without naming any of the generals or experts.
"Our military must be focused on decisive and overwhelming victory and cannot be burdened with the tremendous medical costs and disruption that transgender in the military would entail," he said.
Sanders said Trump had "extensive discussions with his national security team" and Defense Secretary Jim Mattis was informed after the president made the decision on Tuesday.
"This was about military readiness," Sanders told a briefing. "This was about unit cohesion. This was about resources within the military, and nothing more."
The Pentagon earlier referred questions about Trump's decision to the White House.
Critics said the health costs of caring for transgender service members were a tiny portion of the military's healthcare budget and that Trump's policy change was based on prejudice.
A MATTER OF TIMING
Trump's tweet caught some White House officials by surprise.
A senior administration official said Trump had been determined to act for a while but the question was the timing, with advisers split on whether to conduct reviews before announcing the move.
The announcement at least temporarily changed the subject in Washington, where Trump's administration faces investigations into his presidential campaign's contacts with Russia and has struggled to win major legislative victories.
It was not the first time Trump has targeted transgender people since taking office in January. In February, he rescinded protections for transgender students put in place by Obama that had let them use bathrooms corresponding with their gender identity.
Senate Armed Forces Committee Chairman John McCain - the most prominent military veteran in Congress, who was a Navy pilot and prisoner of war during the Vietnam War - called Trump's announcement unclear and inappropriate until a Pentagon study on the issue is completed and reviewed by Mattis, the military leadership and lawmakers.
Tony Perkins, president of the Family Research Council advocacy group, was among those praising Trump, saying, "Our troops shouldn't be forced to endure hours of transgender 'sensitivity' classes and politically correct distractions."
Under Obama, the Pentagon last year announced it was ending its ban on transgender people serving openly, calling the prohibition outdated.
The Defense Department had been expected to start allowing transgender people to begin enlisting this year. But Mattis on June 30 approved a six-month delay in that step.
Advocacy groups said Trump's policy was open to legal challenge under the U.S. Constitution's guarantee of equal protection under the law.
"CHEAP POLITICAL POINTS"
American Civil Liberties Union attorney Joshua Block said Trump had rejected the "basic humanity" of transgender service members.
"There are no cost or military readiness drawbacks associated with allowing trans people to fight for their country," Block said. "The president is trying to score cheap political points on the backs of military personnel who have put their lives on the line for their country."
Obama's defense secretary, Ash Carter, last year cited a study by the RAND Corporation think tank saying there were about 2,500 transgender active-duty service members and 1,500 reserve transgender service members.
"To choose service members on other grounds than military qualifications is social policy and has no place in our military," Carter said on Wednesday, noting there were already transgender individuals serving "capably and honorably."
The House of Representatives' top Democrat, Nancy Pelosi, noted that a Pentagon-commissioned study determined the cost of providing medically necessary transition-related care involving transgender service members would amount to about one-100th of 1 percent of the military's healthcare budget.
The study put the cost at $2.4 million to $8.4 million a year of the more than $50 billion the Defense Department spends on healthcare.
"Once again, President Trump has shown his conduct is driven not by honor, decency, or national security, but by raw prejudice," Pelosi said.
Retired Colonel Sheri Swokowski, 67, the highest-ranking openly transgender veteran, joined the criticism.
"Transgender people are serving today knowing that their leader frankly doesn't trust them," she said. "The bottom line is that this does great harm to people who simply want to serve their country."
U.S. Representative Ileana Ros-Lehtinen, a Republican whose son is transgender, said on Twitter: "No American, no matter their sexual orientation or gender identity, should be prohibited from honor + privilege of serving our nation."
Transgender celebrity Caitlyn Jenner defended "patriotic transgender Americans" in the military and asked Trump on Twitter, "What happened to your promise to fight for them?"
Canada's military also took to Twitter on Wednesday to say it welcomes citizens "of all sexual orientations and gender identities," adding the hashtag #DiversityIsOurStrength.
But Vicky Hartzler, a Republican congresswoman, praised Trump for changing Obama's "costly and damaging policy."
The US military's ban on gays serving openly in the armed forces ended under Obama in 2011 after Congress passed legislation in 2010 reversing a law dubbed "don't ask, don't tell" that had forced the ouster of thousands of service members and others to hide their sexual orientation.
The Pentagon under Obama also opened all combat roles in the military to women.
The U.S. military at times has been in the vanguard of social progress. Trump's action came on the 69th anniversary of Democratic President Harry Truman racially integrating the armed forces, years before the 1950s and 1960s civil rights battles.
(Reporting by Doina Chiacu and Phil Stewart in Washington; Additional reporting by Steve Holland, Lawrence Hurley and Susan Heavey in Washington, and Daniel Trotta, Andrew Seaman, Joseph Ax and Jonathan Allen in New York; Writing by Will Dunham; Editing by Jonathan Oatis and Bill Trott)
(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)