A former Passaic County high school teacher who offered three students money in exchange for sex has been sentenced to three years in prison and parole supervision for life, authorities said.

Thomas Weir, 56, who taught at John F. Kennedy High School in Paterson, was arrested outside a restaurant on Feb. 23, 2013 after an investigation by the county sheriff’s and prosecutor’s office.

“The investigation revealed that Mr. Weir was engaging in sexually explicit conversations with three students at Kennedy High School over Facebook and through text messages,” Passaic County Prosecutor Camelia M. Valdes said in a statement.

Investigators at the time said Weir offered a student $50 to perform a sex act. A month later, he made similar offers with three of his former seventh-grade students – boys who ranged in age from 13-17, officials said. Weir was arrested after an investigator posed as one of the victims online and was propositioned, authorities have said.

Weir taught in Paterson schools for more than two decades and moved to the high school level shortly before his arrest.

Weir pleaded guilty in August to attempted endangering the welfare of a child, endangering the welfare of a child and engaging in prostitution, according to Valdes. As part of his plea, Weir agreed to surrender his New Jersey teaching license, Valdes said.

Judge Marilyn C. Clark sentenced Weir on Friday to three years in prison to be served at the Adult Diagnostic and Treatment Center in Avenel, a prison that provides treatment for repetitive and compulsive male sex offenders. After his release, Weir will be required to register as a sex offender under Megan’s Law, the prosecutor said.

In 2004, Weir was accused of inappropriate sexual conduct by a student at Passaic County Community College, where the teacher had been working as an adjunct professor, according to news reports. A jury acquitted Weir of the charge.