The man accused of shooting a Harris County sheriff's deputy at a gas pump has accepted a capital murder plea agreement for the 2015 killing.

Shannon Miles was given a life sentence is prison Wednesday.

 He was accused of gunning down Dep. Darren Goforth at a gas station in 2015.

Miles' lawyers have previously asserted that he has had mental issues, including schizophrenia and psychotic episodes. 

Miles was placed in a state mental facility shortly after his arrest and later found incompetent to stand trial -- but that ruling was reversed this year. 

Goforth worked pumping gas near Telge and West Road when was shot to death without warning. Miles is accused of firing wordlessly, continuing to shoot after Goforth fell to the ground.

Harris County Sheriff Ed Gonzalez issued a statement on Wednesday in response to the plea agreement. It appears here in full:

“Two years ago, the Harris County Sheriff’s Office family suffered a terrible loss when our brother, Deputy Darren Goforth, was ambushed and gunned down. Deputy Goforth served the residents of Harris County for nearly a decade. He will always be remembered for his service, his bravery, and his sacrifice.

"Today, the Goforth family and the Harris County Sheriff’s Office family are pleased to learn that justice will be served upon Deputy Goforth’s killer. We are grateful to Special Prosecutor Brett Ligon and his team for their hard work to bring this terrible case to a fair resolution.

"To the Goforth family, you will always be part of our family and our thoughts and prayers remain with you.

"Finally, I want to thank the men and women of the Harris County Sheriff’s Office family who faithfully serve our community with courage and dignity. We are grateful for our community’s support and trust, which we hold sacred. Thank you."