Updated 5:31 p.m. ET

The suspected shooter in the Dallas attack on police officers was a former enlisted Army reservist who served for six years, including a stint in Afghanistan, personnel officials said on Friday.

Micah Xavier Johnson, 25, who allegedly shot and killed five law enforcement officers -- including four Dallas police officers and a Dallas Area Rapid Transit officer, two of whom were also military veterans -- entered the Army Reserve in March 2009 at age 18 from his home of record at the time in Mesquite, Texas, the service said in a statement to Military.com.

Johnson was a private first class (E-3) at the time of discharge in April 2015, the Army said. His junior rank after so many years in the service may stem from a sexual harassment case he faced, a source told Military.com. Johnson was a carpentry and masonry specialist with a military occupational specialty of 12W, the service said.

Johnson was assigned to an engineer brigade in Seagoville, Texas, in September 2013 and was activated that same month to support Operation Enduring Freedom in Afghanistan, where he served with the 420th Engineer Brigade from November 2013 to July 2014. He ended his time in uniform with the same unit.

Johnson's tour in Afghanistan was cut short after a female soldier filed a sexual harassment complaint against him, according to Bradford J. Glendening, an attorney in the Reserve Judge Advocate's General (JAG) Corps and a member of the 22nd Legal Operations Detachment, a trial defense unit whose headquarters is based at Fort Sam Houston in San Antonio, Texas.

Glendening, who represented Johnson in the case, said the woman requested a protective order against Johnson for herself, her family and place of residence -- and that he undergo mental health counseling.

"It takes a lot for someone to be kicked out of a military combat theater like that," the attorney said in a telephone interview.

Glendening said Johnson's chain of command wanted him to receive an "other than honorable" discharge -- the most severe type of administrative discharge -- and that he submitted a document for Johnson to receive a "general discharge" in September 2014.

"Every soldier who's being kicked out of the Army has some problems," Glendening said. "I got the impression that he had a bad attitude but nothing beyond that. I remember him being slightly disrespectful of me ... He never referred to me as 'sir' or by my rank."

At the same time, Glendening added, "He never made any remarks that were threatening to me or that he wanted to seek retaliation with the Army."

It wasn't immediately clear what type of discharge Johnson ultimately received. The information from the Army didn't indicate whether it was honorable or not.

Johnson's awards included the Afghanistan Campaign Medal with campaign star; the Army Achievement Medal; the National Defense Service Medal; the Global War on Terrorism Service Medal; the Army Service Ribbon; the Armed Forces Reserve Medal with "M" Device; and the NATO Medal.

Johnson was killed by police using an armed explosive delivered by a robot, a tactic that may have been a first, police said.

Law enforcement officials were still trying to confirm a motive for the killings but Dallas Police Chief David O. Brown said Johnson was upset by the two recent high-profile shootings of black victims by white police officers.

"He was upset about Black Lives Matter. He said he was upset about the recent police shootings," Brown said. "The suspect said he was upset at white people. The suspect stated he wanted to kill white people, especially white officers."

The information on Johnson released by the Army did not make clear whether he had received advanced marksmanship training.

During the shooting, Johnson was using a long rifle and firing .223-caliber rounds, the civilian version of 5.56mm rounds used by U.S. military and NATO forces, according to Cedric Alexander, a law enforcement analyst. "They do extreme damage," he told CNN.

The attack, described as the deadliest against U.S. police since the Sept. 11, 2001, terrorist attacks, also left seven other officers and two civilians wounded. Former military personnel were also identified among the victims.

Brent Thompson, among those killed in Dallas, was a former U.S. Marine who had served in Iraq and Afghanistan to train local police, Fox News reported. The 43-year-old was a newly married grandfather who joined the Dallas Area Rapid Transit police department in 2009, the news organization reported.

Patrick Zamarripa, 32, who was also slain in the attack, was a Navy veteran who had survived three tours in Iraq before joining the Dallas police department about five years ago, Stars & Stripes reported.

--Editor's note: This story has been updated with additional information about the gunman's military service.

-- Brendan McGarry can be reached at brendan.mcgarry@military.com. Richard Sisk can be reached at Richard.Sisk@Military.com.