The man identified as 25-year-old Micah Johnson told authorities he was upset about the fatal police shootings of two black men earlier this week and wanted to exterminate whites, "especially white officers," officials said.
He was killed by a robot-delivered bomb after the shootings, which marked the deadliest day for U.S. law enforcement since the Sept. 11, 2001, terrorist attacks. In all, 12 officers were shot.
In Georgia, Missouri and Tennessee, authorities said gun-wielding civilians also shot officers in individual attacks that came after the black men were killed in Louisiana and Minnesota. Two officers were wounded, one critically.
President Barack Obama and Texas Gov. Greg Abbott asked for the public's prayers. In a letter posted online Friday, Abbott said "every life matters" and urged Texans to come together.
"In the end," he wrote, "evil always fails."
A military lawyer says Johnson was accused of sexual harassment by a female soldier when he served in the Army in Afghanistan in May 2014. Lawyer Bradford Glendening, who represented Johnson, said Johnson was sent back to the U.S. with the recommendation he be removed from the Army with an "other than honorable" discharge.
Glendening said Johnson was set to be removed from the Army in September 2014 because of the incident. Instead, Johnson got an honorable discharge the following April - for reasons Gardening doesn't understand.
Johnson was a private first class from the Dallas suburb of Mesquite with a specialty in carpentry and masonry. He served in the Army Reserve for six years starting in 2009 and did one tour in Afghanistan from November 2013 to July 2014, the military said.
RELATED: Dallas shooting suspect wanted to kill white cops, police say
After the attack, he tried to take refuge in a parking garage and exchanged gunfire with police, Police Chief David Brown said.
The suspect described his motive during negotiations and said he acted alone and was not affiliated with any groups, Brown said.
Johnson was black. Law enforcement officials didn't disclose the race of the dead officers.
The bloodshed unfolded just a few blocks from where President John F. Kennedy was slain in 1963.
The shooting began Thursday evening while hundreds of people were gathered to protest the killings in Baton Rouge, Louisiana, and suburban St. Paul, Minnesota. Brown told reporters that snipers fired "ambush-style" on the officers. Two civilians were also wounded.
Watch: Mayor Mike Rawlings and Police Chief David Brown speak
Authorities initially blamed multiple "snipers" for Thursday's attack, and at one point said three suspects were in custody. But by Friday afternoon, all attention focused on Johnson, and state and federal officials said the entire attack appeared to be the work of a single gunman.
With the lone shooter dead, Mayor Mike Rawlings declared that the city was safe and "we can move on to healing." He said the gunman wore a protective vest and used an AR-15 rifle, a weapon similar to the one fired last month in the attack on an Orlando, Florida, nightclub that killed 49 people.
When the gunfire began, the mayor said, about 20 people in the crowd were carrying rifles and wearing protective equipment. That raised early concerns that they might have been involved. But after conducting interviews, investigators concluded all the shots came from the same attacker.
A Texas law enforcement official identified the man killed in the parking garage as Johnson. The official spoke on the condition of anonymity because he said he was not authorized to release the information.
Around midday, investigators were seen walking in and out of a home believed to be Johnson's in Mesquite.
In Washington, the nation's top law enforcement official, Attorney General Loretta Lynch, called for calm, saying the recent violence can't be allowed to "precipitate a new normal."
Lynch said protesters concerned about killings by police should not be discouraged "by those who use your lawful actions as a cover for their heinous violence."
The other attacks on police included a Georgia man who authorities said called 911 to report a break-in, then ambushed the officer who came to investigate. That sparked a shootout in which both the officer and suspect were wounded but expected to survive.
READ MORE: POLICE OFFICERS 'AMBUSHED' FRIDAY IN MISSOURI, GEORGIA
In suburban St. Louis, a motorist shot an officer at least once as the officer walked back to his car during a traffic stop, police said. The officer was hospitalized in critical condition.
And in Tennessee, a man accused of shooting indiscriminately at passing cars and police on a highway told investigators he was angry about police violence against African-Americans, authorities said.
Video from the Dallas scene showed protesters marching along a downtown street about half a mile from City Hall when shots erupted and the crowd scattered, seeking cover. Officers crouched beside vehicles, armored SWAT team vehicles arrived and a helicopter hovered overhead.
READ MORE: FAYETTEVILLE POLICE REPORTS RECEIVING MORE THAN 60 THREATS FRIDAY
Demonstrations were held in several other U.S. cities Thursday night to protest the police killings of two more black men: A Minnesota officer on Wednesday fatally shot Philando Castile while he was in a car with a woman and a child, and the shooting's aftermath was livestreamed in a widely shared Facebook video. A day earlier, Alton Sterling was shot in Louisiana after being pinned to the pavement by two white officers. That, too, was captured on a cellphone video.
The Dallas shootings occurred in an area of hotels, restaurants, businesses and some residential apartments only a few blocks from Dealey Plaza, the landmark made famous by the Kennedy assassination.
The scene was chaotic, with officers with automatic rifles on the street corners.
Marcus Carter, 33, was in the area when people started running toward him, yelling about gunshots. Carter said the first shot sounded like a firecracker. But then they proceeded in quick succession, with brief pauses between spurts of gunfire.
PHOTOS: Shots fired during downtown Dallas protest
"It was breaks in the fire," he said. "It was a single shot and then after that single shot it was a brief pause. And then it was boom boom boom boom boom! Pause. Boom boom boom boom boom!"
Video posted on social media appeared to show a gunman at ground level exchanging fire with a police officer who was then felled.
The mayor said one of the wounded officers had a bullet go through his leg as three members of his squad were fatally shot around him.
RAW VIDEO: President Obama's statements on Dallas shooting
"He felt that people don't understand the danger of dealing with a protest," said Rawlings, who spoke to the surviving officer. "And that's what I learned from this. We care so much about people protesting, and I think it's their rights. But how we handle it can do a lot of things. One of the things it can do is put our police officers in harm's way, and we have to be very careful about doing that."
Few details about the slain officers were immediately available.
Four of the dead were with the Dallas Police Department, a spokesman said. One was a Dallas Area Rapid Transit officer. The agency said in a statement that 43-year-old officer Brent Thompson, a newlywed whose bride also works for the police force, was the first officer killed in the line of duty since the agency formed a police department in 1989.
CLICK HERE FOR MORE ABOUT THE OFFICERS
"Our hearts are broken," the statement said.
Theresa Williams said one of the wounded civilians was her sister, 37-year-old Shetamia Taylor, who was shot in the right calf. She threw herself over her four sons, ages 12 to 17, when the shooting began.
Michael Krol was confirmed to have been killed in Thursday's shooting, according to the Wayne County Sheriff's Department, where he worked before joining the Dallas Police Department.
Patrick Zamarripa's father confirmed on Facebook that his son was one of the officers killed in the shootings. Zamarripa had joined the Dallas Police Department five years ago after serving three tours in Iraq with the Navy, his father told the Washington Post.
RELATED: Local, national reaction to Dallas police shooting
Omar Cannon, 44, Misty McBride, 32, and Jesus Retana, 39, are three other mass-transit officers who were injured during the attack. A spokesperson for the agency said they are expected to recover from their injuries.
Other protests across the U.S. on Thursday were peaceful, including in New York, Atlanta, Chicago and Philadelphia. In Minnesota, where Castile was shot, hundreds of protesters marched in the rain from a vigil to the governor's official residence.
Associated Press writers Terry Wallace, Jamie Stengle, Paul Weber and Emily Schmall in Dallas; Amy Shafer, Sarah Rankin and Benjamin Dashley in Chicago; and Christine Armario in Los Angeles also contributed to this report.
Report a Typo