A suspect who was killed by police after snipers shot 12 Dallas officers, five fatally, "wanted to kill white people, especially white officers," police chief David Brown said.

The man was killed after authorities cornered him in a garage at El Centro Community College. After several hours of negotiations, lasting into the early hours of Friday morning, officials exchanged gunfire with the suspect and "saw no other option" but to kill him by detonating a bomb, Brown said.

"Other options would have exposed our officers to grave danger," he said.

Brown said the suspect, who he would not identify, told a hostage negotiator that he was upset about the Black Lives Matter movement and the recent police shootings of black men elsewhere in the U.S.

"The suspect stated he wanted to kill white people, especially white officers," Brown said. "The suspect stated that he was not affiliated with any groups and he stated that he did this alone."

Nonetheless, officers took three other people into custody.

Dallas Mayor Mike Rawlings praised the team who took down the suspect.

"The good news: He's gone off the face of the Earth," Rawlings told MSNBC.

The city's downtown was in lockdown Friday after Thursday night's ambush, which marked the deadliest day for law enforcement since Sept. 11, 2001.

Earlier, the suspect had told police negotiators that "the end is coming" and that "there are bombs all over the place in this garage and downtown," Brown said.

President Barack Obama, who was in Poland for a NATO meeting, condemned the "vicious, callous and despicable attack."

"I believe I speak for every single American when I say that we are horrified over these events and that we stand united with the people and the police department in Dallas," the president said.

The chaos started when at least two snipers fired from an elevated position on police officers minutes before 9 p.m. local time (10 p.m. ET), Brown said. He called it an "ambush-style" shooting.

"We believe that these suspects were positioning themselves in a way to triangulate on these officers from two different perches in garages in the downtown area, and planned to injure and kill as many law enforcement officers as they could," he told a news conference earlier — noting that some victims were shot in the back.

Related: Witnesses Recount Dallas Shooting Horror

Other suspects might still be at large. "We're hopeful that we have got everybody, but we don't know that for sure," Rawlings told NBC's TODAY.

He said the suspects in custody were "being pretty tight-lipped," but their motives were clear. "It's simple ... they wanted to kill police officers. And sadly, they did."

Rawlings didn't elaborate any further on the motives or on who the suspects were, and said authorities were "not ruling anything out," including terrorism.

This map gives a sense of how much of Downtown #Dallas is shut down right now https://t.co/5PdWdI6QWV @NBCDFW pic.twitter.com/TSw1RpIMzZ — Ben Russell (@BenRussellNBC5) July 8, 2016

The FAA ordered a temporary flight restriction over Dallas and there were extensive sweeps of downtown for explosives, but none were found.

Packed Command Post operations tonight. We all knew the fallen. #dallasshooting pic.twitter.com/px7Xw67syF — Maj. Max Geron (@MaxDPD) July 8, 2016

The casualties included eight Dallas police officers and four Dallas Area Rapid Transit (DART) officers, the mayor told NBC News Friday morning. Earlier, officials had said 11 officers had been shot.

Four of the five slain officers were Dallas police, and the fifth was a DART officer. A civilian was also wounded, authorities said.

About 800 people were at the demonstration, and around 100 police officers were assigned to the event and the surrounding area. The shooting occurred after the demonstration ended and as a march was taking place just several blocks from Dealey Plaza, where President John F. Kennedy was assassinated in 1963.

Related: Deadliest Attacks on U.S. Law Enforcement Since 1900

"Our worst nightmare happened," Rawlings said earlier. "It is a heartbreaking moment for the city of Dallas."

"We heard shots, we smelled gunpowder, and that's when everything got really intense and surreal," a witness told MSNBC. "We just started to run and grab kids."

A DART (Dallas Area Rapid Transit) police officer receives comfort at Baylor University Hospital emergency room entrance on July 7, 2016 in Dallas, Texas. Ting Shen/The Dallas Morning News / AP

Police distributed a photo of a man they called a "person of interest." The person in that photo turned himself in, police said, and was later released. It does not appear he was part of the four suspects later mentioned by Brown.

#LAPD stands with the City of #Dallas. We will wear our mourning bands in their honor. #PrayForDallas pic.twitter.com/dLgJHxJ9ke — Chief Charlie Beck (@LAPDChiefBeck) July 8, 2016

Men & women of law enforcement selflessly run into harm's way to save the lives of others. May God protect them and bring peace upon Dallas. — Ted Cruz (@tedcruz) July 8, 2016

Attorney General Kamala Harris said the shootings in Dallas were "a grave reminder of the dangers our law enforcement officers face each day in service of their communities."

The violence put other cities on alert as well. The NYPD's Counterterrorism Bureau said in a statement it was "monitoring the developing events" in Dallas.

The demonstration in Dallas was one of several held across the country Thursday over the police shootings of two black men, Alton Sterling in Baton Rouge, Louisiana, Tuesday and Philando Castile Wednesday in a St. Paul, Minnesota suburb.

In St. Paul, a crowd estimated to be more than a thousand strong gathered outside a school where one of those men killed, Philando Castile, worked as a kitchen supervisor.

In Baton Rouge, mourners gathered in a "second line" parade for Alton Sterling, who was killed by police Tuesday in an incident recorded on video by a bystander. The Department of Justice has opened a civil rights investigation into that shooting.

"It can be any brother or sister out here. This ain’t just started; they’ve been killing us,” Chermicka Brown, a friend of Sterling’s who joined protesters outside the store where he was shot, told NBC affiliate WVLA in Baton Rouge.

Brown, the Dallas police chief, said his force was "heartbroken."

"We're hurting. Our profession is hurting. Dallas officers are hurting," he said. "There are no words to describe the atrocity that occurred to our city. All I know is that this must stop, this divisiveness between our police and our citizens."