Now playing: Watch this: Dallas police killed in ambush

Michael Kevin Bautista/Facebook

A shooting that left five police officers dead and seven others wounded Thursday night in downtown Dallas was live-streamed.

The three-minute video, streamed by Dallas resident Michael Kevin Bautista, shows police officers crouching and lying prone behind department cruisers as shots ring out at a demonstration in response to this week's deadly police shootings in the US. By early Friday morning, the video had been viewed more than 4 million times.

"Holy shit. Holy shit," Bautista says into his phone as he records what appears to be an exchange of gunfire between officers and a gunman. "They're shooting right now, and there's an officer down. They're moving in on somebody. I think they might have got somebody."

Dallas police later said that one suspect tied to the sniper attacks was killed by a police robot bomb after a standoff and that several others were in custody.

The live-stream of the shooting is the second gruesome broadcast in two days on Facebook, whose stated mission is to help people throughout the world to connect and share. What began as a way for people to post photos and organize get-togethers has morphed into a catalyst for political debate and social unrest. Facebook is now one of the largest online communities in the world, with more than a billion people using it each day.

In the three months since launch, the new Facebook Live new broadcast feature has become a mirror of people's lives, relaying video from their phones of everything from the inspirational to the tragic.

Mark Zuckerberg, Facebook's co-founder and CEO, said in a statement shortly before the Dallas attacks that the graphic images being shared on his service were heartbreaking. But, he said, the violence "reminds us why coming together to build a more open and connected world is so important -- and how far we still have to go."

Apple CEO Tim Cook sent tweets quoting the civil rights icon Martin Luther King Jr., along with a statement in support of the fallen officers in Dallas. "Justice cannot be gained through violence," Cook tweeted.

President Barack Obama condemned the Dallas shootings as "a vicious, calculated and despicable attack on law enforcement."

During the live-streamed video of the Dallas attacks, Bautista described his location downtown and what he saw. He also reassured those watching on Facebook that he was all right. He was eventually instructed to leave his position, which he said was behind a tree. Others posted video from their own vantage points, expressing shock and confusion as the shootings happened.

Dallas Police Chief David Brown said in a statement that the officers were fired upon in a high-powered-rifle attack from above the rally.

Thursday evening's live-stream came less than a day after Philando Castile's girlfriend live-streamed on Facebook the immediate aftermath of his shooting by a police officer in Minnesota.

US Attorney General Loretta Lynch, in a press conference, called this a week of profound grief and heartbreaking loss, affirming that the Department of Justice will provide any assistance it can.

"Do not let this week precipitate a new normal in this country," Lynch said Friday.

Update, July 8: New information has been added throughout the morning.

CNET's Erin Carson contributed to this story.

This article also appears in Spanish. Read: Tiroteo fatal contra policías en Dallas se transmitió en vivo por Facebook