A judge sentenced a former Concord High School teacher to 3 1/2 years in state prison for sex-related crimes involving a student at the school.

Manchester resident Joshua Harwood, 39, could have seven months shaved off his sentence if he successfully completes a sex offender treatment program in prison, said Deputy Merrimack County Attorney George Waldron, the prosecutor in the case.

Harwood faced 29 felony charges, including prostitution involving a minor, manufacture of child sexual abuse images, and payment to observe sex with a person.

Last month, he pleaded guilty in Merrimack County Superior Court to two charges — manufacture of child sexual abuse images and human trafficking — and prosecutors dropped the remainder, Waldron said.

Waldron said the victim, who was 17 when their relationship started, agreed to the outcome.

“There was actual contact at one time. Beyond that it was all video,” Waldron said.

With the conviction, Harwood should never be able to teach again, he said.

Harwood’s defense attorney, Elroy Francis Sequeira, would not comment for this article.

Harwood also has a suspended sentence of 7 1/2 to 15 years. If he gets in trouble anytime over the next decade, a judge could send him back to prison.

Police have said that Harwood began a relationship with a Concord High School student in January 2019, when Harwood was not teaching at the school. Police said Harwood paid for sex and for watching the boy perform a lewd act via video.

Each time, police said, he would send payments via Venmo, a mobile payment service. The activity stopped for about a year, according to police, and then resumed in March 2020.

Initially, Harwood’s mother and wife said he was a great son, husband and father and urged a judge to release him on bail before trial, a request Superior Court Judge John Kissinger refused.

Only Harwood’s father was present for his sentencing hearing Tuesday, and he said nothing, Waldron said.

Harwood was hired by the Concord School District in July 2020. The victim contacted Concord High School officials in December, police said, when he believed Harwood was posing online as a high school student seeking relationships with other teenagers.

Harwood was fired after his arrest in February 2021.

Authorities said Tuesday that Harwood used the Concord High School internet to access Grindr, a dating site used by gay, bisexual and transgender people. He appeared to make contact with potential partners while at his desk at school.