DALLAS — Two snipers opened fire on police officers during protests in Dallas on Thursday night, killing four officers and injuring seven others, the police chief said.

A statement from Dallas police Chief David Brown released by a city spokeswoman said “it appears that two snipers shot (11) police officers from elevated positions during the protest/rally.”

He said the snipers fired upon officers “ambush style” and added that police believe the suspects may have planted a bomb in downtown Dallas. The FBI and ATF were on scene, canvassing the area.

Early Friday, police said a suspect was in custody. But no further details were available.

The gunfire broke out around 8:45 p.m. Thursday while hundreds of people were gathered to protest fatal police shootings this week in Baton Rouge, La., and suburban St. Paul, Minn.

The protesters had gathered after a Minnesota officer on Wednesday fatally shot Philando Castile while he was in a car with a woman and a child in a St. Paul suburb. The aftermath of the shooting was purportedly 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 Department of Justice announced that it would monitor the investigation by the Minnesota Bureau of Criminal Apprehension. Gov. Mark Dayton said he and other state officials would seek more direct involvement.

“Nobody should be shot and killed in Minnesota for a tail light being out of function,” Dayton said. “Would this have happened if those passengers would have been white? I don't think it would have.”

The Hennepin County Medical Examiner said Castile, 32, of St. Paul, died of multiple gunshot wounds but did not give details about his injuries.

Video footage from the scene in Dallas showed that protesters were marching along a street in downtown, about a half-mile from City Hall, when the shots erupted and the crowd scattered, seeking cover.

Texas Gov. Greg Abbott released a statement saying he has directed the Texas Department of Public Safety director to offer “whatever assistance the City of Dallas needs at this time.”

Abbott expressed his condolences to the Dallas law enforcement community.

“In times like this we must remember — and emphasize — the importance of uniting as Americans,” Abbott said.

The search for the gunman stretched throughout downtown, an area of hotels, restaurants, businesses and some residential apartments. The scene was chaotic, with helicopters hovering overhead and officers with automatic rifles on the 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 downtown told the newspaper that the shooters “were strategic. It was tap tap pause. Tap tap pause.”

The gunshots in Dallas came amid protests nationwide over the recent police shootings.

In New York City, demonstrators filled Times Square. In Los Angeles, they marched down Martin Luther King Jr. Boulevard. In Chicago, they blocked traffic. In Washington, they gathered in front of the White House.

Many held signs stating “Black Lives Matter.”

Protests also took place in Atlanta and Philadelphia.

The Los Angeles Times and Washington Post contributed.