A man charged with murder in the ambush of a suburban Houston sheriff's deputy had a history of mental illness and was once declared mentally incompetent, according to authorities and his former attorney.

Shannon J. Miles, 30, was being held without bond after an initial court hearing Monday. Prosecutors accuse him of opening fire from behind on Harris County Sheriff's Deputy Darren Goforth on Friday night in what the sheriff called a "cold-blooded assassination."

Goforth was shot 15 times, Harris County District Attorney Devon Anderson said in court.

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," that authorities believe the 47-year-old deputy was targeted because he was in uniform and that there is no evidence Goforth knew Miles.

Anthony Osso, one of Miles' two court-appointed attorneys, told The Associated Press that his client intends to plead not guilty.

Miles' criminal history dates back to 2005 and includes an arrest in Austin in 2012 that led to Miles being sent to a state mental hospital for several months.

In 2012, the Travis County District Attorney's Office charged Miles with aggravated assault with a deadly weapon after he got into a fight at a homeless shelter over a remote control, prosecutor Joe Frederick said. Miles was found to be mentally incompetent in October 2012 and he was sent to North Texas State Hospital in Vernon, Texas.

"From this case, you could never tell what would happen" in the future, Frederick said, adding that prosecutors treated the case as a "very serious offense" and had offered Miles a plea agreement of seven years in prison. Miles was declared mentally competent in February 2013, but the charge was dropped after the victim could not be located, Frederick said.

Jon Evans, Miles' attorney in the Austin case, said medical privacy laws prevent him from offering any details about Miles' mental illness history. But he was told by Miles' mother that her son had a lifelong history of mental illness.

At the time of the case in 2012, Miles "suffered from severe mental illness," Evans said.

Miles also has three convictions for resisting or evading arrest, as well as convictions for disorderly conduct with a firearm, criminal mischief and giving false information to police. Records show he was sentenced to several short stints in jail, from six to 10 days.

From fall 2003 to spring 2004, Miles attended Prairie View A&M University. He also attended the University of Houston for a time.

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

Goforth's funeral is scheduled for Friday.