At first, peace.

Anger, not violence. Marching, not name-calling.

The protesters marched down Main Street. They turned south on Field. And the Dallas police proudly chronicled it all on Twitter – the “enough is enough” chants, the “Black Lives Matter” signs.

The evening was so harmonious that protesters posed for photos with officers, a moment of cooler heads prevailing on a sweltering Texas night after the consecutive fatal shootings of black men by police officers in Louisiana and Minnesota.

And then, mayhem.

“Shots fired, shots fired,” an officer screamed into his radio, just about 9 p.m. “We’ve got a guy with a long rifle. We don’t know where the hell he’s at.”

What unfolded over the next several hours – 12 officers shot, a chaotic hunt for a gunman, a battle that echoed off office buildings and, finally, a bomb explosion – turned the streets of downtown Dallas into an urban combat zone.

It was the most vicious, direct attack on U.S. law enforcement in decades. Five officers died. Seven more were wounded. And the nation was horrified.

This account of the ambush in Dallas is based on police communications, witness accounts and a review of cellphone videos taken by those brave, or brazen, enough to capture the horror. The images almost immediately began circulating on social media.

‘LIKE A LITTLE WAR’

Officers lay in the streets, some mortally wounded. Protesters dropped for cover. Police unholstered their guns.

At first, as they dove behind cars, officers struggled to find where the bullets were coming from. Was there more than one shooter? The sound of sharp rifle fire bouncing off tall buildings could have been the work of multiple shooters. Initial reports said officers were being ambushed by no less than three shooters.

But it was a one-man campaign, waged by ex-Army carpenter Micah Johnson – first in a street assault and then from multiple floors above his targets below. Dallas Mayor Michael Rawlings said Johnson “was a mobile shooter that had written manifestos on how to shoot and move, shoot and move, and he did that.”

Robert Rodriguez, 30, was driving through the city with his 14-year-old son. He saw the protest. And then – bang, bang, bang, bang. Then a pause. And then another barrage of gunfire.

“Like a little war,” he said.

Rodriguez circled the block and then spotted the gunman shooting a rifle at police from his hip. Officers crouched against a building, returning fire. Another officer raced over in his patrol car and emerged shooting. Johnson continued to move and fire, unwounded and unfazed.

The gun battle soon coalesced around one building: El Centro College. On video, Johnson is seen using the college’s pillared entrance as a firing point to target police trying to advance on him. Johnson’s vehicle, a black SUV registered to his mother, appears to be parked nearby, its hazard lights flashing.

Another video, shot from the nearby Bank of America building, shows Johnson taking cover behind a pillar a few feet from his vehicle. He pulls his weapon – likely a Soviet-style rifle judging by its profile – to his cheek and fires multiple rounds before calmly and deliberately moving to another column, his rifle at the ready.

Given his Army duties, it is unlikely Johnson’s apparent proficiency with his weapon came solely from his time in the service. At his home, police later found a diary with entries on combat tactics.

Moments later, in some of most gruesome footage from the evening, Johnson advances through a hail of gunfire, cuts a wide arc around a police officer crouching behind one of the entrance’s pillars, and fires point blank into the officer’s back, shooting repeatedly as the officer collapses.

Johnson eventually enters the college, moving through a series of connected buildings before barricading himself on the second floor, where he continues shooting through an open window.

“He’s in that damn building there,” an officer shouted into his radio. “I hear shots from that building.”

A few blocks away, in November 1963, another killer shot from a window: Lee Harvey Oswald

CHASE, NEGOTIATIONS – THEN A BLAST

Officers raced up to the 14th floor of a nearby building, hoping to get a look at Johnson. They reported seeing him through an open window, his rifle hanging out. SWAT officers moved in.

“We’re taking fire and returning fire,” an officer radioed.

Negotiations began. Johnson told the authorities that he was upset about the recent police shootings. He wanted to kill white people – police officers, preferably. He bragged about leaving bombs in nearby buildings, although none were found. He kept shooting.

Dallas Police Chief David Brown was managing the operation, getting reports from officers trying to talk to the gunman.

He was still shooting, swearing at officers and seemingly uninterested in a peaceful surrender.

In the Dallas Police Department’s operations room, Brown “asked for options to take him out,” according to an account provided by the mayor.

Police hatched a novel plan.

They brought in a robot normally used for entering an area to detonate or remove explosives. Only this time, the robot had a different mission. Police attached a bomb and sent the robot to kill the man who had taken the lives of five of their own.

There was a loud boom and then, finally, quiet.

“No one was heartbroken that he wouldn’t come out,” Rawlings said later.

On Friday, back at the scene of the carnage, Ossie Boddie, 34, recalled how the protest began so peacefully.

“It was all love, man. We were here for a peaceful march,” Boddie said. “There was no ‘F— the police!’ Even the police were smiling. There were women and children. It wasn’t an aggressive crowd.”

Bouquets of flowers sat at the base of three flagpoles where the shooting began.

A red T-shirt tied around one of the poles read “Police Lives Matter.”