A man accused of fatally shooting a Texas sheriff's deputy at a gas station pleaded guilty Wednesday to capital murder and accepted a sentence of life in prison without the possibility of parole, reports the Associated Press.

The plea by Shannon Miles, of Houston, allowed him to avoid a possible death sentence for the August 2015 slaying of Darren Goforth. The 47-year-old Harris County sheriff's deputy was shot 15 times while at a suburban Houston gas station where he was putting fuel in his patrol car.

Prosecutors had said Miles ambushed Goforth, a deputy for 10 years, simply because he was a law enforcement officer.