A Vineyard Haven man will go to state prison for 10 to 13 years after he pleaded guilty Wednesday in Dukes County superior court to several charges, including rape of a child by force.

David L. Thrift Jr., 31, will serve his time at the Massachusetts Correctional Institution at Cedar Junction, a maximum security prison in Walpole.

According to the superior court, Mr. Thrift also pleaded guilty to rape of a child under 16 with a minimum of 10 years age difference and was ordered to serve 10 to 13 years, concurrent with first count.

Mr. Thrift was facing up to two life sentences in prison. Jury selection began for his superior court trial on Tuesday morning and was continuing Wednesday when a plea agreement was reached before the Hon. Cornelius J. Moriarty 2nd, who is presiding over the fall session of superior court.

Mr. Thrift also pleaded guilty to intimidation of a witness, ordered to spend three to five years in a state prison; assault and battery, ordered to serve two years in a house of correction; and violating an abuse prevention order, ordered to one year in a house of correction and a $25 fine. All the sentences will be served concurrently, and Mr. Thrift will not be eligible for parole until after he serves 10 years, which was a mandatory sentence.

The charges stem from a July night in 2011, when Mr. Thrift’s wife called the police to report that he had attacked her at their Vineyard Haven home. The couple, their three young daughters and a 15-year-old female had spent the day on the beach, where Mr. Thrift had been drinking, according to statements recounted in the police report. After everyone had gone to bed, the mother was called to the teenager’s room, where she found her husband assaulting the girl. Confronted, he allegedly assaulted his wife and then fled the house.

After taking the wife’s statement, the police took her to the hospital and began searching for Mr. Thrift. Meanwhile, Mr. Thrift returned to the house and, according to statements given to police, raped the teenager at knife point. Police found Mr. Thrift at his home and arrested him. At the time, he was under an abuse prevention order.

In November, Tisbury police Sgt. Robert Fiske, the officer in charge when police responded to the scene, was dismissed from his job.

Mr. Thrift also pleaded guilty to two counts of solicitation to commit a felony. The charges came from allegations that while incarcerated at the Dukes County House of Correction, he offered a fellow inmate money to kill a Cape and Islands district attorney and his teenaged victim. He was ordered to serve two and a half years in a house of correction for each count, concurrent with the other sentences.

Mr. Thrift was represented by Robert Hofmann, who is with the Committee for Public Counsel Services. Mr. Hofmann did not return a call for comment.

The prosecutor in the case was Essex County assistant district attorney Kate B. MacDougall. The case was transferred to Essex County after Mr. Thrift was charged with making threats against the Cape and Islands district attorney. Essex County District Attorney Jonathan Blodgett said the plea bargain spared the teenaged victim from going through a trial.

“Anytime you have a child rape case, that is certainly a heinous and deplorable crime, and you couple that with threats on the life of a prosecutor . . . the case was not just extremely serious but a recipe for chaos if not addressed,” he said.

“I’ve very pleased this case was resolved prior to trial,” he added. “Our goal was always to seek justice and minimize the trauma to the victim, and I think we achieved both of those goals in this case.”

As for Mr. Thrift’s sentence, “On balance, I think justice was served,” he said, adding that the victim didn’t have to go through the trial.

Tisbury police Det. Mark Santon, who was the lead investigator on the case, said he wasn’t happy with the length of the sentence but he agreed that the plea was in the best interests of the victim.

“It makes me sick to my stomach knowing what he did,” he said. Detective Santon said he traveled to Arkansas last week to talk to the teenaged victim about the trial and discuss ways she could testify in court by video or email. But she was on board with coming to testify, he said. “We spent time with her last week, and still, at the eleventh hour . . . we had plane tickets for her, she was on board, at the last minute she didn’t do it,” he said.

“She didn’t change her story at all,” he added. “She wanted him to go to jail. She wanted something done to him.”

When it comes to the victim of the crimes, he said, the motto is “do no further harm.”

With the 10-year mandatory sentence, Mr. Thrift will not be eligible for parole before that time, he said.

Detective Santon also said that Mr. Thrift’s ex-wife, who was flown up from Arkansas, “had some closure and got to make a statement to the judge.”

With the plea bargain, he said, “nobody is going to go away happy.”

“I’m not happy with the number of years,” the detective said. “I’m sure he’s not happy that he’s going to spend 13 years in a state prison as a child rapist.”