Mr. Burgamy’s lawyer, a federal public defender, declined to comment.

Prosecutors said that Mr. Wilson had regularly mailed drugs from his pharmacy to Mr. Burgamy since at least last August.

Mr. Burgamy advertised and sold the drugs using encrypted email accounts on the dark web, giving a cut of the profits to Mr. Wilson through Bitcoin payments, wire transfers and bundles of cash sent through the mail, authorities said.

In court documents, the F.B.I. said it started investigating Mr. Burgamy last December after learning about his account on the dark web. Unlike most sites on the traditional internet, the dark web uses technology that lets both sides of an online interaction hide their identity and location from each other and law enforcement.

In January, agents with the F.B.I. and the Food and Drug Administration began making undercover purchases from Mr. Burgamy, who went by the name NeverPressedRx and had a reputation for selling high-quality drugs. The agents ordered the pills from Virginia, where they were also delivered.

In an email to an undercover agent, Mr. Burgamy said he was running a “five-star business,” according to court documents.

“We will never succumb to purchasing drugs off the street that could be potentially tampered with for your safety,” he wrote in a post, according to prosecutors.

He told potential buyers, “all of our stock comes directly from a U.S. pharmacy.”

That pharmacy, federal agents learned, was Hyrum’s Family Value Pharmacy.