HOUSTON -- The man accused of fatally shooting a suburban Houston officer spent time in a mental hospital following a 2012 arrest, according to a prosecutor.

Shannon J. Miles is charged with capital murder in the death of Harris County Sheriff's Deputy Darren Goforth.

Miles' criminal history includes an arrest in 2012 following a fight at a homeless shelter he was staying at in Austin.

Get Breaking News Delivered to Your Inbox

Joe Frederick, a prosecutor with the Travis County District Attorney's Office, said Miles was found to be mentally incompetent in October 2012 after being charged with aggravated assault with a deadly weapon. He was sent to North Texas State Hospital in Vernon, Texas.

Frederick says Miles was declared competent in February 2013, but the charge was dropped against Miles after the victim could not be located.

Miles appeared briefly in state District Court in handcuffs and shackles on Monday. The 30-year-old Houston resident said little, other than to answer the judge's questions. He is being held without bond.

Harris County District Attorney Devon Anderson would not comment on a motive, saying investigators were still trying to figure that out. When asked if it might be connected to heightened tensions around the country between law enforcement and civilians, Anderson said, "I have no idea whether it does or not."

This weekend, Sheriff Ron Hickman said the attack was "clearly unprovoked," and there is no evidence that Goforth knew Miles. "Our assumption is that he (Goforth) was a target because he wore a uniform," the sheriff said.

Hickman also made controversial statements linking the crime to the Black Lives Matter movement.

"We've heard black lives matter, all lives matter, well cops lives matter too, why don't we just drop the qualifier we all matter," he said. Some have called the statement insensitive.

President Obama called Goforth's killing contemptible and "an affront to civilized society." Mr. Obama spoke from Alaska Monday with Goforth's wife, Kathleen, conveying his condolences and telling her he will keep highlighting the uncommon bravery of police officers.

Anderson read the probable cause statement in court, saying that police first received a call at 8:20 p.m. Friday. When authorities arrived at the gas station in the Houston suburb of Cypress, they found Goforth, a 10-year veteran of the force, face-down. He was already dead, she said.

Surveillance video from the gas station shows that Goforth, 47, had just come out of a convenience store after he had pumped gas and that Miles got out of his red truck, she said.

"He runs up behind Deputy Goforth and puts the gun to the back of his head and shoots. Deputy Goforth hits the ground and then he continues to unload his gun, shooting repeatedly into the back of Deputy Goforth," Anderson said.

Shannon Miles is escorted out of a courtroom after a hearing Monday, Aug. 31, 2015, in Houston. Miles has been charged with capital murder in the death of Harris County Sheriff's Deputy Darren Goforth. He is being held without bond. (AP Photo/Pat Sullivan) Pat Sullivan, AP

Goforth was shot 15 times and a witness saw the shooting, Anderson said. She added that the shell casings match the .40-caliber Smith and Wesson handgun found at Miles' home.

The killing evoked strong emotions in the area's law enforcement community, with Hickman linking it to heightened tension over the treatment of African-Americans by police. Goforth was white and Miles is black.

The nationwide "Black Lives Matter" movement that formed after 18-year-old Michael Brown was shot and killed by a white police officer in Ferguson, Missouri has sought sweeping reforms of policing. Related protests erupted in Texas recently after a 28-year-old Chicago-area black woman, Sandra Bland, was found dead in a county jail about 50 miles northwest of Houston three days after her arrest on a traffic violation. Texas authorities said she committed suicide but her family is skeptical of that.

"We've heard Black Lives Matter, All Lives Matter. Well, cops' lives matter, too," Hickman said Saturday.

Deray McKesson, a leader in the Black Lives Matter movement, told the Houston Chronicle: "It is unfortunate that Sheriff Hickman has chosen to politicize this tragedy and to attribute the officer's death to a movement that seeks to end violence."

Miles' criminal record begins in 2005, when he was convicted of criminal mischief, giving false information to police and resisting arrest, according to records. In 2006, he was convicted of disorderly conduct with a firearm and sentenced to a maximum of 15 days in jail. He was convicted of evading arrest in 2007, and his most recent conviction came in 2009 for again resisting arrest. Records show he was sentenced to several short stints in jail, anywhere from six to 10 days.