The shooter, barricaded in a downtown Dallas parking garage, bantered with negotiators during an hours-long standoff.
He did not seem nervous and said he was not afraid to die.
He told the armed officers facing him that he had been preparing for the assault, vowing that he "wanted to kill white people, especially white officers," according to Dallas police.
As investigators later discovered, the gunman's online activities provided other hints to his motivation.
Micah Xavier Johnson, a 25-year-old black man, showed interest in groups affiliated with the black separatist movement. He had "liked" Facebook pages for the founder of Nation of Islam and for the Black Riders Liberation Party, which are classified as hate groups by the Southern Poverty Law Center.
The rough outlines of Johnson's life that emerged after the shootings in Dallas paint a portrait of a U.S. Army veteran who was violently disturbed by what he saw as a police war against black Americans. He was determined to fight back.
Johnson's ambush took place during a demonstration to protest recent deadly police shootings of two African American men in Louisiana and Minnesota. As hundreds of people marched through downtown Dallas, officials say Johnson opened fire, killing five police officers and wounding nine others.
Friends and family expressed shock over the shootings, saying the attack ran counter to what they knew of Johnson. He had no criminal history or known ties to terrorist groups.
"It's the quiet ones that just do the most devastating stuff," his friend Israel Cooper told the Associated Press. "You never see it coming. But then it's more expected, like 'I should have known.' "
Cooper frequently played basketball with Johnson at a park near his house in Mesquite, a suburb southeast of downtown Dallas. Johnson, who went by Xavier, had a "cool vibe," Cooper said, and never seemed like "a violent or rough dude."
In Johnson's neighborhood, near Interstate 20, fast food joints and gas stations dominate the commercial arteries, with the residential areas tucked behind high walls.
On the last road in a neighborhood dotted with large houses and big front yards, law enforcement and media swarmed a two-story home with a stone facade and a portico above the front entrance.
Inside, detectives found bomb-making materials, ballistic vests, rifles, ammunition and a personal journal "of combat tactics," a Dallas Police Department news release said. Law enforcement officials believe Johnson frequently went to shooting ranges.
He joined the Army Reserve in March 2009 and served in a troop program unit in nearby Seagoville for four-and-a-half years, according to his service record. Members of the Army Reserve program typically spend one weekend per month on duty and perform two weeks of additional training each year.
He deployed to Afghanistan in 2013 as part of Operation Enduring Freedom and served eight months as a carpentry and masonry specialist with the 420th Engineer Brigade.
Johnson received several medals for his tour of duty in Afghanistan, including an Army Achievement Medal and a NATO Medal.
A woman who served with Johnson in Afghanistan posted on Facebook that Johnson had been "my battle buddy, my brother in arms."
"I served with him most of all my army career," Sarah Castañeda wrote. "I've been feeling so heavy hearted about what's going on but this just hits too… close."
In a Facebook post, Johnson's sister mourned the loss of her brother and questioned why he had gone to the downtown demonstration.
"I keep saying it's not true… my eyes hurt from crying," Nicole Johnson wrote in a post she later deleted. Minutes later, she posted again. "The news will say what they think but those that knew him know this wasn't like him. … This is the biggest loss we've had."
Dallas activists said they did not recognize Johnson or his name, and had never seen him at a protest.
In addition to his interest in separatist groups, Johnson had "liked" a page for the Huey P. Newton Gun Club, named for the Black Panther Party's co-founder. The group, founded last year, teaches its members self-defense and conducts what it calls "armed patrols" through neighborhoods where the police have killed black men.
In a press release issued last year, the group said police agencies with officers who shoot and kill black people "protect the interests of the ruling class, much as they did in the past with slave patrols in the South and strike breakers in the late 19th and early 20th century."
"We'd never seen him and we don't know him," said member Erick Khafre by phone. "The gun club isn't affiliated with him in any way."
In his Facebook photo, Johnson wore a purple, yellow and gold dashiki and thrust his fist into the air. His cover photo displayed the red, black and green stripes of the Pan-African flag.
Last week, Johnson shared a video on Facebook of pilot whales being killed in the shallow waters off the Faroe Islands in the North Atlantic Ocean.
"Look at the joy on their faces," Johnson wrote. "Why do so many whites (not all) enjoy killing and participating in the death of innocent beings?"
He continued: "The church members and regular citizens (offspring of terrorist invaders) who stood around watching, cheering, eating food with their families while watching one of our ancestors be beaten, noose tied around their neck, hung up high for all to see… then they all stand around and smile while their picture is taken with a hung, burned and brutalized black person."
Times staff writers Duara reported from Mesquite and Nelson from Los Angeles. Times staff writers W.J. Hennigan and Del Quentin Wilber in Washington contributed to this report.