A Hays man was sentenced Monday in Ellis County District Court to 21 years in prison for two charges of rape involving an underage victim.

Andrew Dale Hansen, 32, previously had served six years in prison for a previous rape conviction, also involving a minor.

Hansen was released from prison in April, and faced charges of rape and failure to register as a sex offender by August, Ellis County Attorney Tom Drees said.

He was charged with rape for having sexual relations with a 14-year-old, and also faced a charge of having sexual intercourse with a person who was physically powerless, according to court documents.

Hansen entered a guilty plea earlier this month, using an Alford plea. The voluntary plea resulted in his sentence being shortened slightly. He was sentenced as if the victim was 16, Drees said. The sentence for a younger victim could have been as high as 25 years, he said.

Both of Hansen’s convicted crimes were committed while he was on post-release supervision.

The prison sentence of 21 years and one month was given by Chief Judge Glenn Braun for the rape charges, with an additional 34 months for failing to register as an offender.

“He will spend all of his 30s and 40s in prison,” Drees said.

Hansen also was sentenced to lifetime probation following his release from prison.

His previous conviction also involved a 14-year-old girl. Both victims lived in Hays at the time, Drees said.