 -- The suspected gunman in the attack on Dallas law enforcement was accused of sexual harassment during his military deployment in Afghanistan, a military lawyer said.

Micah Xavier Johnson was a private first class in the U.S. Army Reserve serving in Afghanistan when he was accused of sexually harassing a higher-ranking female soldier in May 2014, military lawyer Bradford Glendening told ABC News. Glendening, who represented Johnson in the case, said the woman requested a military protective order against his client.

Johnson had been sent to Afghanistan in November 2013 but was sent back to the United States six months after his deployment because of the alleged harassment, Glendening said. The lawyer added that Johnson's chain of command recommended he be removed from the Army with an "other than honorable" discharge, the most severe administrative discharge. But, ultimately, Johnson was not discharged in this way, Glendening said.

According to the Associated Press, Johnson instead received an honorable discharge in April 2015, for reasons Glendening doesn't understand.

Glendening told ABC News he got the sense Johnson was generally disliked by his unit and was viewed as not exhibiting respect for his commanders.

At least 12 officers were shot, and five of them killed, in downtown Dallas Thursday night, with the shots raining down during a protest against the fatal shootings earlier in the week week by police of two black men: Alton Sterling in Louisiana and Philando Castile in Minnesota. Some of the officers were shot in the back. Two civilians were also injured in the ambush-style shooting, police said.

Johnson, 25, was identified as the suspected gunman. After barricading himself inside a building, Johnson told hostage negotiators he was angry about recent shootings of black men by police and that he wanted to kill white people, especially police officers. He also indicated there were possible explosives in the area, police said.

After the hours-long standoff with law enforcement, Jonson was killed by officers who detonated a bomb delivered by robot, which appears to be the first time the tactic was employed.

The suspect had "plenty of options to give himself up peacefully," Dallas Mayor Mike Rawlings said Friday afternoon. "He had a choice to come out and we would not harm him, or stay in and we would. He picked the latter."

Jeppi Carnegie, owner of Touch of Kindness LLC, said Johnson had worked for the residential health care company since January 2015. He worked from his mother's home in Mesquite and cared for his 21-year-old brother, Carnegie told ABC News.

Carnegie described Johnson as a "good employee" and a "family man" who loved his younger brother. The company never had any issues with Johnson who was always volunteering to work more hours.

Although Carnegie said the company was aware that Johnson was, as Carnegie put it, "pro-black," he wasn't aware of his employee having any affiliations with militant, radical groups. He said he was "surprised and disappointed" when he found out Johnson was a suspect in the Dallas ambush.

ABC News' Stephanie Wash contributed to this report.