HOUSTON –The man charged in the murder of Harris County Sheriff's Deputy Darren Goforth has been ruled competent to stand trial.

Shannon Miles is accused of gunning down Goforth outside a Cypress gas station in 2015.

A now bearded Miles showed little emotion in the courtroom as he entered a plea of not guilty.

This issue of competency has been a back and forth battle between the state and the defense since the beginning.

Harris County Sheriff's Deputy Darren Goforth.

At first, Miles was found incompetent due to his psychiatric state. After spending time in a state mental facility, the state decided he was competent.

But his lawyers weren’t convinced so they asked for another evaluation.

Although, Miles was again found competent to stand trial, defense attorney Anthony Osso says he would now like a doctor to determine his sanity.

“Anytime you have an issue of competency, and you have someone who suffers from mental illnesses that our client suffers from, you have to cover all bases," Osso said.

More than 11,000 people gathered to pay their respects to Harris County Sheriff Deputy Darren Goforth at Second Baptist Church on Sept. 4, 2015.

Osso says Miles suffers from psychosis and schizophrenia and is currently on medication to address those issues.

The cold-blooded murder of deputy Goforth outraged the community and hundreds of people marched in protest. Eleven-thousand people attended his funeral.

It seemed like a clear-cut case: Surveillance video showed Miles at the scene and lead investigators right to his mom's house down the street. He was arrested within hours. Since then, the case has taken many twists and turns.

The emotional “End of Watch” ceremony for Deputy Darren Goforth included the final radio call, the presentation of the flag to his widow Kathleen, a missing man flyover and a 21-gun salute.

Defense Attorney Anthony Osso doesn't deny is client is guilty. but he's arguing against the death penalty because he says Goforth wasn't on duty.

Court documents revealed the deputy, who was married with two young children, met up with his mistress at the gas station.

"People say, 'Oh, he's on duty, we get that he's in uniform.' The question is whether he is in the lawful discharge of an official duty at the time the incident occurs, and there's a big difference," Osso said in a past interview.

Since Goforth's murder, three men in the sheriff's office have been fired in connection with that same mistress. On top of that, the judge in the case stepped down.