WASHINGTON (Reuters) – The top U.S. military officer on Thursday said he made a mistake by joining President Donald Trump as he walked to a church for a photo opportunity after authorities dispersed protesters with tear gas and rubber bullets near the White House.

“I should not have been there,” Joint Chiefs of Staff Chairman General Mark Milley said in a prerecorded video commencement address to the National Defense University due to take place on Thursday. “My presence in that moment and in that environment created a perception of the military involved in domestic politics.”

Milley and Defense Secretary Mark Esper walked with the Republican president during his surprise trip to the historic Saint John’s Church on June 1, during which he held up a Bible for photographers.

Law enforcement used tear gas and rubber bullets to disperse mostly peaceful protesters before Trump crossed the street to the church, drawing condemnation from Democrats and some Republicans.

“As a commissioned uniformed officer, it was a mistake that I have learned from, and I sincerely hope we all can learn from it,” Milley said. His comments were first reported by the New York Times.

Protests spread nationwide in response to the killing of George Floyd, a black man who died after a white police officer knelt on his neck for almost nine minutes in Minneapolis on May 25.