A 20-year-old Berwick man was arrested last week after police said he had been traveling every other day to Lawrence, Massachusetts, to buy the powerful synthetic opioid fentanyl, which he then distributed from his Berwick apartment.

Benjamin Rand of School Street was charged with aggravated trafficking in scheduled drugs after a four-month investigation by state troopers from New Hampshire and Maine, as well as Berwick police officers. His apartment is within 1,000 feet of Knowlton School, raising the severity of the charge.

Rand was arrested Friday as he returned from Lawrence with 20 grams of a substance suspected of being fentanyl, police said. According to police, Rand sold the drug in Maine and New Hampshire.

Berwick police said they are forwarding information about Rand’s supplier in Lawrence to Massachusetts police.

“This investigation has been our agency’s primary focus over the past few months,” said Berwick Police Chief Timothy Towne. “Rand was very casually selling fentanyl within eyesight of the Knowlton School, which educates our fourth- and fifth-graders.”

He was ordered held at the York County Jail on $50,000 cash bail.