Gen Milley (R) was on the walk with the president, as was Defence Secretary Mark Esper (C)
The top US military officer says he was wrong to have joined President Donald Trump during his controversial walk to a damaged church near the White House.
The 1 June event created “a perception of the military involved in domestic politics”, Gen Mark Milley said.
Mr Trump walked to the church and held up a Bible after a peaceful protest at the death of African American George Floyd was forcibly dispersed.
The use of troops to tackle the protests has provoked fierce US debate.
Mr Trump has regularly referred to “law and order”, calling in the National Guard to the US capital, vowing to deploy the military to other cities and condemning violent protests.
Some of the mostly peaceful initial protests following the death of George Floyd in Minneapolis last month did turn violent with looting in several cities.
But since four police officers were charged in connection with the death, the protests have been more peaceful, spawning an international movement against police brutality and racial inequality.
Video footage of the death in Minneapolis shows a white officer kneeling on Mr Floyd’s neck for nearly nine minutes.
What did Gen Milley say?
The chairman of the joint chiefs of staff was speaking in a video for a National Defense University commencement ceremony.
He said: “I should not have been there. My presence in that moment and in that environment created a perception of the military involved in domestic politics.
“As a commissioned uniformed officer, it was a mistake that I have learned from, and I sincerely hope we all can learn from it.”
Gen Milley added: “We must hold dear the principle of an apolitical military that is so deeply rooted in the very essence of our republic.”
He also said he was outraged at the “senseless, brutal killing” of George Floyd.
Gen Milley said: “The protests that have ensued not only speak to his killing but also to centuries of injustice toward African Americans.”
The general was wearing battle uniform as he walked with the president and critics said this suggested his support for the deployment of the military against protesters.
Defence Secretary Mark Esper was also on the walk and, although he has not said he was wrong to be there, suggested in a news conference that he thought the walk was for a different purpose of mingling with troops and inspecting damage.
Senior officials told US media that Mr Trump had yelled at Mr Esper after the conference.
A break sure to anger the president
Nada Tawfik, BBC News, New York
This is just the latest sign of growing friction between the White House and the military over how best to deal with the country’s history of racism and the current movement for change.
The chairman of the joint chiefs of staff said it had been a mistake to appear alongside the president during his controversial walk.
The event sparked outrage and debate about the role of the military and the deployment of troops.
In his video clip to graduates at the National Defense University, Gen Milley also acknowledged the military’s mixed record on equality.
This stunning public break is sure to anger President Trump, who has yet to respond.
What happened on the day?
A peaceful demonstration was cleared in Lafayette Square next to the White House with pepper spray and flash-bang grenades so that the president and his entourage could walk to St John’s Episcopal Church.
With the dispersal still ongoing, Mr Trump spoke in the Rose Garden, calling on governors to use the National Guard to “dominate the streets” or he would “deploy the United States military and quickly solve the problem for them”.
Mr Trump, who sees himself as a champion of evangelical and conservative voters, then walked to the church, the basement of which had been burned the previous day, and held up a Bible.
A number of religious leaders criticised his actions. The presiding bishop of the the Episcopal Church, Michael Curry, accused Mr Trump of using the church for “partisan political purposes”.
The Minneapolis community at the heart of the protests is rebuilding after destruction caused by rioting
Mr Trump said “most religious leaders loved” his visit to the church and denied having any role in dispersing protesters beforehand.
His latest tweet on the issue on Thursday again praised the security forces.
Donald J. Trump
✔@realDonaldTrump
Our great National Guard Troops who took care of the area around the White House could hardly believe how easy it was. “A walk in the park”, one said. The protesters, agitators, anarchists (ANTIFA), and others, were handled VERY easily by the Guard, D.C. Police, & S.S. GREAT JOB!
What are the latest developments on George Floyd’s death?
Country music band Lady Antebellum have changed their name to Lady A. Antebellum in the US refers to the slavery period before the Civil War
An amendment in the Armed Services Committee of the Republican-led Senate now requires Mr Trump to rename military bases named after Confederate generals, something he has refused to do. Prospects the amendment will pass the full Senate though are unclear
Europe could see a surge in Covid-19 infections as a result of massive Black Lives Matter rallies, EU officials say.