The Pentagon will not immediately change its policy after US President Donald Trump said transgender service members would no longer be allowed to serve, the most senior US military official said.

"There will be no modifications to the current policy until the president’s direction has been received by the Secretary of Defense and the secretary has issued implementation guidance,” Joint Chiefs of Staff Chairman Gen. Joseph Dunford wrote in a letter to the Pentagon's top officials that was published Thursday on Twitter.

"In the meantime, we will continue to treat all of our personnel with respect," Dunford added.

Trump on Wednesday broke with a campaign pledge to protect LGBT rights, writing on Twitter that the United States will not accept or allow transgender individuals to serve in any capacity in the military.

INFOGRAPHIC: Mapping hate - The rise of hate groups in the US

"Our military must be focused on decisive and overwhelming victory and cannot be burdened with the tremendous medical costs and disruption that transgender (individuals) in the military would entail," he said.

The announcement appeared to blindside the Pentagon, which referred all inquiries on the matter to the White House, where spokeswoman Sarah Huckabee Sanders was unable to answer basic questions about the issue, including whether service members who are on active duty would be dismissed.

Trump's tweets drew quick, sometimes scathing criticism from many legislators, both Democratic and Republican, as well as many military troops and retirees. But social conservatives applauded.

Protesters demonstrated in several cities as well as outside the White House.

The American Civil Liberties Union said its chances of getting a court to block Trump's proposed ban might depend on the details of the plan.

While Trump asserted in his decision that transgender service members saddle the Pentagon with "tremendous medical costs", the Rand Corporation estimates in a Pentagon-commissioned study that those costs would amount to between $2.4m and $8.4m annually.

To put that in perspective, the US military spends $41.6m annually on Viagra, an erectile-dysfunction medication, according to the Military Times.

The total estimated number of transgender members of the US military varies, with estimates ranging between 2,000 and 15,000.