President Trump said Thursday he is doing the military a "great favor" by moving to ban transgender people from serving.

"As you know, it's been a very complicated issue for the military, it's been a very confusing issue for the military, and I think I'm doing the military a great favor," Trump told reporters in Bedminster, N.J., according to a pool report.

Trump declared on Twitter July 26 the U.S. "will not accept or allow transgender individuals to serve in any capacity in the U.S. Military."

Pentagon officials have said they will not implement the ban unless they get a formal policy directive from the president dictating how the ban would work.

On Wednesday, five transgender people serving in the U.S. military sued Trump and top Pentagon officials because of the planned ban.

Despite widespread criticism of Trump's decision, the president asserted Thursday he is supported by the transgender community.

"I have great respect for the community," Trump said. "I think I've had great support, or I've had great support from that community. I got a lot of votes. But the transgender, the military's working on it now. … It's been a very difficult situation, and I think I'm doing a lot of people a favor by coming out and just saying it."