The New York City Medical Examiner has confirmed that two young people who died at the Electric Zoo festival on Randalls Island over Labor Day weekend took fatal doses of drugs sold on the street that are known as “molly.”

The third day of the festival was canceled at the request of city authorities after the two overdose victims, Jeffrey Russ, 23, of Rochester, and Olivia Rotondo, 20, of Providence, R.I., collapsed with high body temperatures. Their deaths came after a string of similar overdoses since March at dance concerts around the country — in Boston, Seattle, Miami and Washington, D.C.

Toxicology results showed Ms. Rotondo died from acute intoxication after taking pure MDMA, the euphoria-producing drug sold on the street in pill form as ecstasy and in powdered form as molly, said Ellen Borakove, a spokeswoman for the medical examiner’s office.

Mr. Russ had taken a fatal mix of MDMA and methylone, a closely related stimulant that is also often sold under the name molly. Methylone is one of several stimulants and psychedelic drugs often used by drug dealers to cut MDMA, law enforcement officials said.

Both substances have long been popular among people who go to raves and dance festivals. They are amphetamines that flood the brain with neurotransmitters like dopamine and serotonin, making people affectionate, euphoric and emotionally open. Users at dance events say the high helps contribute to an illusion of unity and communal feeling. However, they can also wreak havoc with the body’s cells, causing a person’s temperature to rise until organs shut down.

A third New Yorker, Matthew Rybarczyk, 20, died on July 15 of an overdose of methylone after attending a different electronic dance music concert on Governors Island, the medical examiner’s office said.

On average, only about four people a year have died in New York City from MDMA overdoses, a tiny fraction of the 700 deaths from drugs, city health officials say. From 2000 to 2011, there were 43 deaths from ecstasy, compared with 4,676 cocaine overdoses and 4,151 heroin overdoses.

Developed in 1912 by Merck, MDMA was not marketed until the 1970s, when psychiatrists prescribed it to help people open up during therapy.

Dance-music fans starting using the drug under the street name ecstasy in the 1980s, starting in Ibiza’s discos, then in the rest of Europe and the United States.

Perhaps inevitably, ecstasy pills became adulterated with other substances. There was another increase in use in 2000 and 2001, the last time dance music surged in popularity.