Dallas Police Chief David Brown told a news conference that two snipers in elevated positions shot 11 officers, killing three, in what appeared to be a coordinated attack. Some of the victims were shot in the back.
Police reported that two more officers have been confirmed dead.
Police said one suspect they had engaged in a shootout had been arrested, and a bomb squad unit was investigating a suspicious package found near the suspect’s location.
A second “person of interest” had turned himself in, they said, although there was no word on the arrest of the second sniper. Brown also said no motive for the shooting had been uncovered yet.
“Our worst nightmare has happened,” Mike Rawlings, mayor of the Texas city, told a news conference.
“It is a heartbreaking morning to lose these officers who served our citizens,” he said.
Television footage showed a heavy police presence, with officers taking cover behind vehicles on the street.
Separately, police said they were questioning occupants of a Mercedes they had pulled over after the vehicle sped off down a downtown street with a man who threw a camouflaged bag inside the back of the car.
Police said three other people in custody, two from inside the Mercedes and another woman detained near a downtown garage.
The U.S. Federal Aviation Administration issued a temporary flight restriction over downtown Dallas after the shooting. Facebook also activated safety checks for its users.
The shooting happened as otherwise mainly peaceful protests unfolded around the U.S. after the shooting of Philando Castile, 32, by police near St. Paul, Minnesota, late on Wednesday.
His girlfriend posted live video on the internet of the bloody scene minutes afterward, which was widely viewed.
Castile’s death occurred within a day of the shooting of Alton Sterling, 37, in Baton Rouge, Louisiana.
Sterling was killed during an altercation with two white police officers. Graphic video of that incident caused an outcry on social media.
“Our thoughts and prayers are with the Dallas law enforcement community and the Dallas Area Rapid Transit officers killed and injured this evening,” Governor Greg Abbott said in a statement.
In Chicago, protesters shut down a stretch of the Dan Ryan Expressway – one of Chicago’s main arteries – for about 10 minutes on Thursday.
In New York, several hundred protesters blocked traffic in Times Square in the heart of Manhattan, chanting “Hands up, don’t shoot.” More than a dozen arrests were made, the New York Police Department said.
In St. Paul, about a thousand people gathered outside the governor’s mansion, chanting “Hey hey, ho ho, those killer cops have got to go,” and other slogans.
Minnesota governor Mark Dayton made a brief appearance in an attempt to quell the crowd. He said earlier a state investigation was already under way.
“Would this have happened if the driver and the passengers were white? I don’t think it would have,” Dayton told reporters, speaking of the Castile shooting.
“So I’m forced to confront that this kind of racism exists, and it’s incumbent upon all of us to vow and ensure that it doesn’t happen and doesn’t continue to happen,” he said.
State investigators later identified Minneapolis area police officer Jeronimo Yanez as the patrolman who fatally shot Castile during a traffic stop.
U.S. President Barack Obama described the killings as tragedies.
“All of us as Americans should be troubled by these shootings, because these are not isolated incidents. They’re symptomatic of a broader set of racial disparities that exist in our criminal justice system,” he said after arriving in Poland for a NATO summit.
The use of force by police against African-Americans in cities from Ferguson, Missouri, to Baltimore and New York has sparked periodic and sometimes violent protests in the past two years and has spawned the #BlackLivesMatter movement.
Anger has intensified when the officers involved in such incidents have been acquitted in trials or not charged at all.
“I was already fuming when I woke up this morning over Baton Rouge, but for it to happen here again just pushed me right over the edge,” said truck driverThomas Michaels, 42, who was among the protesters in St. Paul.
“We live in a racist society where black lives don’t matter, my kids’ lives don’t matter and I’m sick of it. I don’t even know if it can be fixed,” he said.
Another protester, retail worker Tanya McDonald, 28, said: “What gets me is how many people are failing to see that this is happening almost every day. We’re dying, we’re being killed off by people hiding behind a badge and no one’s doing anything to stop it.”
The Washington Post said Castile was at least the 506th person and 123rd black American shot and killed by police so far in 2016, according to a database it has set up to track such deaths.
In Texas, a man attacked the headquarters of the Dallas Police Department last June with gunfire and explosives before being shot dead in a standoff with police snipers.