Media playback is unsupported on your device Media caption Amateur video shows a man with a rifle, hiding behind a concrete pillar and shooting

Five Dallas police officers have been killed and seven wounded by gunmen during protests against the shooting of black men by police, authorities say.

Three people are in custody and one man who was in a stand-off with police shot himself dead, US media said.

Gunfire broke out at around 20:45 local time on Thursday (01:45 GMT Friday) as demonstrators marched through the city.

The protests came after this week's deaths of Philando Castile in Minnesota and Alton Sterling in Louisiana.

The Dallas attack marks the deadliest day for US law enforcement officers since the 9/11 attacks in 2001.

President Barack Obama, who is visiting Poland, said it was a "vicious, calculated and despicable attack on law enforcement". He said the entire city of Dallas was grieving and the "tight-knit US police community feels this loss to their core".

Dallas Police Chief David Brown said the suspects were all believed to have been working together, using rifles to carry out attacks while the protest rally was drawing to a close.

Two snipers had fired from "elevated positions", shooting some officers in the back.

"We believe that these suspects were positioning themselves in a way to triangulate on these officers from two different perches... and planned to injure and kill as many law enforcement officers as they could," Chief Brown said.

Officers later surrounded a car park near El Centro College, as an armed man fired off rounds with a rifle.

Chief Brown said the suspect had told negotiators that "the end is coming" and that he was going to attack more officers and had "bombs all over the place".

US media say the man is now dead from a self-inflicted gunshot wound and the stand-off is over, although the police have yet to confirm this.

Media playback is unsupported on your device Media caption Eyewitness: "All of the cops were getting shot."

Police are continuing to sweep the downtown area. No explosives have been found so far.

A woman who was in the vicinity of the suspect at the car park is being questioned.

Police also said officers had intercepted a car after a person threw a camouflaged bag into the back and sped off. Two occupants were detained.

Chief Brown said that officers had been shot "ambush style" by sniper fire.

Image copyright AP Image caption A transport police officer comforts a relative at Baylor University Hospital

Image copyright Getty Images Image caption The mayor of Dallas said this was a "heartbreaking moment for the city"

Image copyright AP Image caption President Obama said the tight-knit US police community "feels this loss to their core"

One of those killed was Brent Thompson, 43, a transport police officer with the Dallas Area Rapid Transit (DART). He is the first DART officer to be killed in the line of duty.

Amateur video footage showed one police officer approaching a gunman and taking cover behind a concrete pillar. The gunman shoots the officer at least twice, leaving him motionless, and then flees.

Dallas Mayor Mike Rawlings told the NBC Today programme that the suspects so far were not co-operating and were "tight-lipped".

"We're glad that we took down one of the suspects. We hope we have got everybody, but we can't be sure," he said.

He said that two civilians were also injured in the shootings, one man and one woman.

The woman, named by her family as Shetamia Taylor, was shot in the leg while protecting her children and is recovering in hospital.

'In a state of shock' - eyewitness reports

Media playback is unsupported on your device Media caption People in Dallas started running when they heard dozens of gunshots

Brendan Tyler Hester, photographer: "Once the shots rang out everyone started running. When I turned around to see where my friends were, I saw a policeman next to me get shot. He dropped to the ground screaming. The police shouted at us to run so I did and ended up at the bottom of a parking lot.

"There was a shooter on the top of it so I could see all of the shots coming down on to where the police were. I could hear more shouting and screaming. I was trapped with three or four other guys... in the line of fire, so we just had to make a run for it."

Tracey Jones, student: "We all started to run but I'm disabled and walk with a cane and got knocked over. The police started to shoot back. It looked as if they were shooting into the crowd, even though they weren't, but they were shooting over everyone in the direction of the shooters. It was complete panic.

"Along with my friend and about 15 other people, I made it to a train station a few blocks away and we took shelter there for around four hours. I'm in a state of shock, really. I just can't believe this happened in my city."

Mr Obama said that "anyone involved in these senseless murders will be held fully accountable".

He said the attacks were a "wrenching reminder" of the sacrifices made by law enforcement officers.

The Officer Down Memorial website says 53 US officers have died in the line of duty in 2016, 21 of them as a result of gunfire. The toll does not include those killed in Dallas.

Mr Obama added that "when people are armed with powerful weapons it makes attacks like these more deadly and more tragic", a subject that, he said, must be addressed in "the days ahead".

Police had earlier issued a photo of one man at the rally with a rifle slung over his shoulder, saying he was a suspect.

The man, named as Mark Hughes, turned himself in to police and was later released.

Captured on video

The Dallas protests were among several held across the US over the police use of lethal force against African Americans.

Image copyright AFP Image caption The protesters have been angered by the deaths of black men at the hands of police

Image copyright EPA Image caption The protest was peaceful before the gunfire erupted

Philando Castile was shot dead at a traffic stop in St Paul, Minnesota , on Wednesday, while Alton Sterling was killed by police a day earlier in Baton Rouge, Louisiana.

Both incidents were captured on video, reigniting what has become a national debate.

Pointing to statistics showing African-American citizens are far more likely to be shot by police than whites, Mr Obama has called on law enforcement to root out internal bias.

Are you in Dallas? Were you in the area at the time of the shooting? Please email details of your experiences to haveyoursay@bbc.co.uk.

You can also contact us in the following ways: