CRANSTON, R.I. — A probation officer for juveniles was arrested Tuesday afternoon after police say he sold heroin to an undercover officer.

Michael Ayer, 49, of 46 Frank Rd. in Stoughton, Mass., was arrested on two counts of delivering heroin to a police officer and arraigned at the Rhode Island State Police Lincoln barracks Tuesday afternoon. He will be arraigned on the felony charges in Kent County District Court on Wednesday.

Capt. David S. Neill, commander of the state police detective division, said that when Ayer was arrested around 2 p.m., he was driving his state-registered vehicle and using his state cell phone to conduct the sales.

The State Police High-Intensity Drug Trafficking Area Task Force began the undercover operation last month, acting on a tip from an informant. Neill said that Ayers delivered “numerous bags of heroin” on two different occasions to the undercover officer, who met Ayers at a public area near the Cranston/Providence city line.

According to Neill, Ayers had been a probation officer with the state Department of Children, Youth and Families for the last 14 years. Neill said there was no indication that Ayers had sold to anyone he was supervising.