WASHINGTON (CN) — Top military general Mark Milley said Thursday he should not have joined President Donald Trump in walking to St. John’s Church for a Bible photo op, for which authorities forcefully cleared peaceful protesters to make way for administration officials.

“My presence in that moment and in that environment created a perception of the military involved in domestic politics,” Milley said in a National Defense University commencement ceremony webcast, referring to a photo of him in his combat uniform alongside Trump and his presidential entourage. “As a commissioned uniformed officer, it was a mistake that I have learned from, and I sincerely hope we all can learn from it.”

In the last few weeks, some military officers have disagreed with Trump’s decision to use federal troops to control protests triggered by George Floyd’s death in police custody.

In his commencement speech Thursday, Milley emphasized the military should be above politics.

“We must hold dear the principle of an apolitical military that is so deeply rooted in the very essence of our republic,” the chairman of the Joint Chiefs of Staff said. “It takes time and work and effort, but it may be the most important thing each and every of us does every single day.”

Defense Secretary Mark Esper, who claimed last week in an interview with NBC that he was unaware of his destination when he joined the president on the short walk across Lafayette Square, said in a letter to Congress on Wednesday, signed by both Milley and Esper, that neither official intended to pose with Trump.

“We participated in the walk with the aim of observing damage in Lafayette Square and at St. Johns Church, and meeting with and thanking the National Guard members who were on duty,” they said.

The letter, which was obtained by the Washington Post, came after a June 3 request to schedule a hearing before the House Armed Services Committee about the Defense Department’s role and authority in civilian law enforcement.

Esper and Milley responded after the chair of the committee, Congressman Adam Smith, D-Wash., voiced his “profound frustration” Wednesday that the officials had not yet responded to his request to testify before the committee.

The House Armed Services Committee had asked Esper and Milley to answer questions about the use of military force in responding to peaceful civil rights protests in Washington and plans to deploy active duty troops around the country in the event Trump tried to invoke the Insurrection Act of 1807 to trigger U.S. military involvement in states.

In their response, Esper and Milley said that National Guard troops served in a supporting role in protecting Washington amid protests and that they were preparing active-duty forces to deploy into the nation’s capital only as a precaution, but that the forces “are not currently present and were not ever in the District for purposes of civilian law enforcement.”

Trump does have the power to invoke the Insurrection Act, they confirmed.

“In the event that a president makes such a decision, he may do so without approval from the state government in which the forces are to be used,” they said.

Trump has faced widespread backlash over his photo op at St. John’s Church last week, including from former Defense Secretary Jim Mattis, who issued a scathing rebuke of the use of military force to repel protesters.

“When I joined the military, some 50 years ago, I swore an oath to support and defend the Constitution,” Mattis wrote. “Never did I dream that troops taking that same oath would be ordered under any circumstance to violate the Constitutional rights of their fellow citizens — much less to provide a bizarre photo op for the elected commander-in-chief, with military leadership standing alongside.”

Mattis also said we are “witnessing the consequences of three years without mature leadership.”

“Donald Trump is the first president in my lifetime who does not try to unite the American people — does not even pretend to try. Instead he tries to divide us,” he wrote.