Five police officers were killed and seven wounded during a march against the shooting of black men by police.
Three people are in custody but it is not clear if there were other gunmen.
The protest in Dallas took place after this week's deaths of Philando Castile in Minnesota and Alton Sterling in Louisiana.
The suspect was killed by a police robot using explosives after a stand-off with police following the attacks.
Police Chief David Brown said the gunman was angry following the recent police shootings in the US.
"He said he was upset about Black Lives Matter [protest movement]; he said he was upset about the recent police shootings," Mr Brown told a news conference," he told a news conference.
"The suspect said he was upset at white people. The suspect stated that he wanted to kill white people, especially white officers."
"Negotiations broke down. We had an exchange of gunfire with the suspect.
"We saw no other option but to use our bomb robot and place a device on the extension for it to detonate where the suspect was. Other options would have exposed our officers to grave danger.”
Mr Brown said earlier reports that the suspect committed suicide were not accurate.
"The suspect is deceased as a result of detonating the bomb," said Mr Brown.
Dallas Mayor Mike Rawlings said the police used a robot with explosives to “blast him out”, but added he was not sure how he died or what weapons were found on him.
The suspect apparently told officers that he was upset over recent police shootings of black men and wanted to kill white people, according to officials.
Three people are in custody, Mr Brown said. The fourth suspect died after exchanging gunfire with officers in a city centre parking garage as he reportedly made threats about bombs, according to mayor Mike Rawlings.
Police sealed off the city centre but later tweeted that primary and secondary sweeps for explosives were complete and no explosives had been found.
The gunfire broke out as hundreds of people were gathered to protest over incidents in Baton Rouge, Louisiana, and St Paul, Minnesota.
The Dallas shootings killed four city police officers and one officer with Dallas Area Rapid Transit, which operates buses and the state of Texas's largest municipal rail system.
Mr Brown told reporters the snipers fired "ambush style" on the officers, and Mr Rawlings said two members of the public were wounded in the gunfire.
Video footage from the scene showed protesters marching about half a mile from City Hall, when the shots erupted and the crowd scattered, seeking cover.
Mr Brown said that it appeared the shooters "planned to injure and kill as many officers as they could".
The attacks made Thursday the deadliest day in US law enforcement since the September 11 terrorist attacks in 2001, according to the National Law Enforcement Officers Memorial Fund.
The search for the shooters stretched throughout the city centre, an area of hotels, restaurants, businesses and some residential apartments. The area is a few blocks away from Dealey Plaza, where President John F Kennedy was assassinated in 1963.
The scene was chaotic, with helicopters hovering overhead and officers with automatic rifles on street corners.
"Everyone just started running," Devante Odom, 21, told the Dallas Morning News. "We lost touch with two of our friends just trying to get out of there."
Carlos Harris, who lives nearby, told the newspaper that the shooters "were strategic. It was tap, tap, pause. Tap, tap, pause".
Mr Brown said police do not have a confirmed motive for the attacks or any information on the suspects. He said they "triangulated" in the area where the protesters were marching and had "some knowledge of the route".
Video posted on social media appeared to show a gunman at ground level exchanging fire with a police officer who was then felled.
Authorities have not determined whether any protesters were involved with or were complicit in the attack.
One woman was taken into custody in the same parking garage as the stand-off, Mr Brown said. Two others were taken into custody during a traffic stop.
Mr Rawlings said at a news conference that authorities were asking people to stay away from the city centre: "This is still an active crime scene. We're determining how big that crime scene is."
A map was being posted online showing an area where people should avoid, he said.
Dallas Area Rapid Transit said in a statement that 43-year-old Brent Thompson was the first officer killed in the line of duty since the agency formed a police department in 1989.
"Our hearts are broken," the statement said.
Theresa Williams said one of the injured civilians was her sister, 37-year-old Shetamia Taylor.
Ms Williams said her sister was at the protests with her four sons, aged 12 to 17. When the shooting began, Ms Taylor threw herself over her sons, Ms Williams said. She was undergoing surgery after being shot in the right calf.
Texas governor Greg Abbott released a statement saying he had directed the Texas Department of Public Safety director to offer "whatever assistance the City of Dallas needs at this time".
"In times like this we must remember - and emphasise - the importance of uniting as Americans," Mr Abbott said.