U.S. president Barack Obama said on Friday the attack on Dallas police officers was "vicious, calculated and despicable" and promised justice.

"There is no possible justification for these kinds of attacks or any violence against law enforcement...anyone involved in the senseless murders will be held fully accountable. Justice will be done," Obama said from Poland, reported CNN. He was in Warsaw to attend a NATO summit.

One of the attackers who shot the police officers and was subsequent killed by the police has been identified as a former Army reservist.

Micah Xavier Johnson, 25, served in the Army till April last year and was trained in carpentry and masonry, ABC News reported, citing law enforcement officials.

Johnson wanted to "kill white people", mainly policemen, as he was upset with the killing of black Americans by the police across the U.S., the channel added. 

Johnson was killed by the police — after long hours of negotiation interrupted by bouts of gunfire — using an explosive strapped to a police robot, according to the channel.

Five police officers were fatally shot and six others were injured on Thursday night after snipers opened fire at the police during protests against the killings of two African-American men by the police in Louisiana and Minnesota. One of the suspects who was was being questioned by the police in a parking garage has died, according to CNBC.

The gunfight broke out at around 8:45 p.m. and the police have taken into custody two suspected snipers, one of whom -- a "person of interest" – had surrendered. The police said that a woman was also arrested after an officer saw her and another individual throw a bag into a vehicle and speed off.

According to Brown, the deceased suspect was not cooperating during the negotiation and has claimed that he wishes to kill more officers. The police chief was quoted by the Telegraph as saying that the suspect "has told our negotiators that the end is coming, and he is going to hurt and kill more of us, meaning law enforcement. And that there are bombs all over the place in this garage and in downtown."

The police said that the bomb squad was securing a suspicious package found at the suspect's location.

Dallas Police Chief David Brown was quoted by the Associated Press as saying that the snipers fired on them "ambush style." Mayor of Texas City Mike Rawlings said that a member of the public was also injured.

"Our worst nightmare has happened... It is a heartbreaking morning to lose these four officers who served our citizens," Rawlings was quoted by Reuters as saying.

BREAKING: Union for Dallas police reports fifth officer has died after shooting in Dallas

— Reuters U.S. News (@ReutersUS) July 8, 2016

Several protests were carried out across the country following the fatal shooting of a man, Philando Castile, by a Minnesota police officer on Wednesday at the St. Paul suburb. Castile, a school food services worker, was in a car with his fiancée and their four-year-old child when an officer pulled him over for a broken taillight, CNN reported.

The shooting was live-streamed by Diamond Reynolds, his fiancée.

Thirty seven-year-old Alton Sterling, "the CD man" was shot dead at a convenience store in Louisiana's Baton Rouge on Tuesday. According to reports, he was approached by a homeless man who persistently asked him for money to an extent that Sterling took out his gun. The man called 911 and the police arrived after which they took him to the ground and shot him.

A makeshift memorial was made outside the store where people paid tributes by laying flowers and putting up different signs protesting against the shootings. Prayer vilgils were also held. Almost 1,000 protestors marched up to Fifth Avenue in New York City's Times Square shouting slogans like "Black lives matter!"

The New York Police Department was quoted by Reuters as saying that over a dozen people were arrested during protests at Times Square.

Democrats showed their support for the victims. American President Barack Obama was quoted by CNN as saying: "This is not just a black issue."

Pop star Beyonce posted a message on her website saying: "We are sick and tired of the killings of young men and women in our communities. It is up to us to take a stand and demand that they 'stop killing us'. We don't need sympathy. We need everyone to respect our lives."

Story republished at 9.40 Indian Standard Time with additional details.