Police have identified Micah Xavier Johnson, 25, as the suspect who was killed by police after he shot five officers dead at a protest against police brutality in the United States.

Johnson, a former soldier in the US army, had served in Afghanistan, the army said on Friday. They said he had no criminal record and no ties to "terror" groups. Johnson, according to police, said he was acting on his own.

The shootings took place in the city of Dallas on Thursday night during a peaceful Black Lives Matter protest against police killings of black men across the country.

The officers were shot from elevated positions, the Dallas Police Department said.

Another seven officers and two civilians were wounded, according to the Dallas Morning News newspaper.

Dallas, the third largest city in the state of Texas, is home to an estimated 1.3 million people.

"The suspect said he was upset about Black Lives Matter," Brown told reporters. "He said he was upset about the recent police shootings; the suspect said he was upset at white people.

"The suspect said he wanted to kill white people, especially white officers," he continued. "The suspect stated that we will eventually find the IEDs. The suspect stated he was not affiliated with any groups and he stated that he did this alone."

Johnson exchanged fire with police officers and was then killed when they detonated an small bomb carried by a robot in the parking garage of the El Centro College in the city centre.

Brown said negotiations broke down and police "saw no other option but to use our bomb robot". He said that three other suspects were in custody.

Dallas Mayor Michael Rawlings urged people to join a prayer vigil for the officers who were killed.

Al Jazeera's Heidi Zhou-Castro, reporting from Dallas, said it was "the worst attack on law enforcement officers in the United States" since the September 11 attacks in 2001.

"It is a different Dallas altogether this morning as people awoke to this tragic news," she said.

Country-wide protests

The mainTwitter account associated with the Black Lives Matter movement denounced the killings.

#BlackLivesMatter advocates dignity, justice and freedom. Not murder. — Black Lives Matter (@Blklivesmatter) July 8, 2016

Speaking to Al Jazeera from Washington DC, Debbie Hines, a lawyer and former Baltimore city prosecutor said that "vigilantism is not going to solve any of the problems we have in the US".

"The divisiveness is caused by institutionalised racism in this country, and that's not an easy fix. But I think that on a simplistic level the police have to be retrained," she said.

"One thing we need to do is to get a hold of how pervasive the problem is and that would mean a national database of collections of how many officer-involved shootings and police brutality, as well as officer-involved deaths, that we presently don't have."

The protest in Dallas was called after police killed two black men within 48 hours earlier this week - Alton Sterling in Louisiana on Tuesday and Philando Castile in Minnesota on Wednesday.

Both the mayor and the police chief said the protest was peaceful. Several other protests that took place across the country passed without incident.

Castile was shot dead by a police officer while he was in a car with his partner Diamond Reynolds and her daughter in a St Paul suburb.

READ MORE: Does Black Lives Matter really matter?

Reynolds live streamed the aftermath of the shooting in a widely shared Facebook video.

A day earlier, Sterling was shot in Louisiana after being pinned to the pavement by two white officers. That incident was also captured on a mobile phone video.

Of the 566 people killed by US police so far this year at least 24 percent were black, according to a database compiled by the Guardian media organisation. African Americans make up 13.3 percent of the country's population.

'Vicious, calculated and despicable'

US President Barack Obama, addressing the media in Warsaw where he was attending a NATO summit, called the Dallas incident a "vicious, calculated and despicable attack" for which there was "no possible justification".

"We need to be supportive of those officers who do their job every single day. Today is a wrenching reminder of the sacrifices they make for us. When people are armed with powerful weapons, it makes attacks like these more deadly and more tragic."

OPINION: Ferguson onward - two anniversaries

A day earlier, responding to the recent killings of black men by police, he said that all Americans should be concerned about racial disparities in the criminal justice system.

"I also said yesterday our police have an extremely difficult job and that the vast majority are doing their job in outstanding fashion," Obama said.

'Everyone started running'

Describing the reaction to the Dallas shootings, Devante Odom, 21, told The Dallas Morning News: "Everyone just started running, We lost touch with two of our friends just trying to get out of there."

Carlos Harris, who lives in the city centre, told the newspaper that the gunmen "were strategic. It was tap tap pause. Tap tap pause."

Video footage from the scene showed protesters marching along a street, about half a mile from City Hall, when the shots erupted and the crowd scattered, seeking cover.

"In times like this we must remember - and emphasise - the importance of uniting as Americans," he said, in a statement.