The man who imprisoned three women in his home, subjecting them to a decade of rapes and beatings, pleaded guilty Friday to 937 counts in a deal to avoid the death penalty.

Ariel Castro told the judge he was addicted to pornography, had a “sexual problem” and had been a sexual abuse victim himself long ago.

In exchange for his plea, prosecutors recommended Castro be sentenced to life without parole plus 1,000 years.

Castro, 53, said he understood that he would never get out of prison, saying he expected he was “going to get the book thrown at me.” He later added, “I knew that when I first spoke to the FBI agent when I first got arrested.”

Castro, wearing glasses for the first time in court, was far more interactive than in previous court appearances when he mostly kept his head down and eyes closed. He answered the judge’s questions in a clear, intelligible voice, saying he understood the proceedings and that he would never be released from prison.

Castro, who was born in Puerto Rico, said he could read and understand English well but had trouble with comprehension.

“My addiction to pornography and my sexual problem has really taken a toll on my mind.” He later said he had been a sexual abuse victim as a child, but the judge cut him off.

Near the end of the 2 1/2-hour hearing, the judge accepted the pleas and declared Castro guilty. Sentencing was set for next Thursday.

The deal comes more than a month after a statement issued on behalf of the women said they were “hopeful for a just and prompt resolution” and had “great faith in the prosecutor’s office and the court.”

Castro had been scheduled for trial Aug. 5 on a 977-count indictment, but 40 counts were dropped as part of the plea deal. The indictment included two counts of aggravated murder related to accusations that he punched and starved one woman until she miscarried. The former school bus driver also was charged with hundreds of counts of kidnapping and rape, plus assault and other counts.

He was accused of repeatedly restraining the women, sometimes chaining them to a pole in a basement, to a bedroom heater or inside a van. The charges alleged Castro assaulted one woman with a vacuum cord around her neck when she tried to escape.

The sticking point on a plea deal had been whether the prosecutor would rule out the death penalty.

Assistant Cuyahoga County Prosecutor Blaise Thomas said he wants to make sure Castro will never see the girl he fathered with one of his victims.

Chief Prosecutor Tim McGinty also says the county will use over $20,000 seized from Castro to tear down his house within a month. McGinty said the plan is to also tear down two abandoned houses next door and acquire a vacant lot for a park.

McGinty rejected attempts by Castro to portray himself a victim of a sex addiction.

“He’s a coward and he’s nowhere near the truth,” McGinty said. “He’s in his own world and it’s not a world of regret and remorse. He feels sorry for one person and one person only — himself.”

The three women disappeared separately between 2002 and 2004, when they were 14, 16 and 20 years old. Each said they had accepted a ride from Castro, who remained friends with the family of one of the women and even attended vigils over the years marking her disappearance.

The women —Amanda Berry, Gina Dejesus and Michelle Knight — escaped Castro’s house May 6 when one of them kicked out part of a door and called to neighbors for help. Castro was arrested within hours and has remained behind bars.