NEW YORK — A Buffalo man pleaded guilty Thursday to a narcotics charge in a prosecution that arose after an overdose death at a New York City music festival.

Patrick Morgan, 24, pleaded guilty to one count of conspiring to distribute narcotics, saying he knew he was acting illegally when he agreed to obtain some Ecstasy pills for a friend in August 2013.

"I knew what I was doing was wrong," he told U.S. District Judge Edgardo Ramos in Manhattan.

Jeffrey Russ, 23, of Rochester, collapsed and had a seizure at the August 2013 Electric Zoo music festival on Randall's Island. He had consumed the drug Ecstasy, also known as Molly. His death was blamed on acute intoxication from the combined effect of the pills and hyperthermia.

Authorities said Morgan had previously sold pills to Russ and two others, who pooled their money to buy the pills for use at an electronic dance music concert in Buffalo. They said Morgan's friend, who later bought about 80 pills for the purpose of consuming and distributing them at the New York City festival, passed them to Russ and others. The three-day outdoor festival was attended by more than 130,000 people.

In a release, Manhattan U.S. Attorney Preet Bharara said: "This office remains committed to aggressively pursuing and prosecuting those who peddle this extremely dangerous drug."

Prosecutors and a defense lawyer agreed to a stipulated sentencing guideline range that makes it likely Morgan will face less than a year in prison on a charge that carries a maximum potential sentence of 20 years.

Sentencing is scheduled for March 13. He remains free on bail.