Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Five people were killed when a lone gunman opened fire during an electronic dance music festival at a Mexican resort popular with foreign tourists, authorities said Monday.

"Five people died, four men and one woman," the attorney general of the Mexican state of Quintana Roo said on Facebook Monday morning.

A man with a gun attempted to enter Blue Parrot nightclub in Playa Del Carmen at around 2:30 a.m. Monday but was denied entrance by event security, causing him to open fire, the attorney general said.

The four male victims died from gunshot wounds and the woman appeared to have been killed in a stampede of people as club goers fled the shooting, Attorney General Miguel Angel Pech said at a press conference later Monday. Three of the dead were security personnel.

The victims included two Canadians, one Italian and one Colombian, he said.

An additional 15 people were injured and one person was in serious condition.

Pech said three people were detained for questioning, but it was unclear whether they were involved in the shooting.

"We're aware of another incident where there was an exchange of gunfire, which occurred near the club, but we are investigating if they are related," Pech said.

Earlier Monday, the event's organizers had said four people were killed, three of which were of a part of their security team.

"It is with great sadness to share that police have confirmed reports of a lone shooter outside the Blue Parrot nightclub in Playa Del Carmen earlier today, which resulted in four fatalities and twelve injured," according to a statement posted on The BPM Festival's Facebook page.

The Morning Rundown Get a head start on the morning's top stories. This site is protected by recaptcha

"Three members of the BPM security team were among those whose lives were lost while trying to protect patrons inside the venue," the statement added.

Scottish DJ Jackmaster, who was scheduled to perform at the festival, said in a tweet that four or five people had been fatally shot and "many wounded."

"Someone has come into the club in Playa Del Carmen and opened fire," he wrote.

This is a very very sad situation. Tryna get my head around it still. Thoughts and condolences to all affected — JACKMASTER (@jackmaster) January 16, 2017

A member of the tourist police earlier told NBC News that they could not "discuss this incident because the information is confidential."

Gunshots were reported in or near the Blue Parrot, which is some 45 miles south of Cancun and across the channel from the island of Cozumel.

The organizers of The BPM Festival initially tweeted that "after alleged reports of shots fired this morning at Blue Parrot, all BPM parties are shut down while police investigations are underway."

The tweet was later deleted.

Mexican police agents patrol near a nightclub in Playa del Carmen, Mexico where 5 people were killed, three of them foreigners, during a music festival on Jan. 16, 2017. Stringer / AFP/Getty Images

Hector Escardo told NBC News via Twitter that he got to the Blue Parrot around five minutes before gunfire broke out.

The media industry worker from Los Angeles said the “place was packed, music in full swing” when he heard the first shots.

Escardo “dropped next to the bar, straight on the floor" at the burst of gunfire coming from some 30 feet away.

After another volley of shots rang out, partiers surged toward a fence separating the club from a rocky beach, the 39-year-old said.

He watched “all these people go crazy and jump over."

View of the Blue Parrot nightclub in Playa del Carmen, Mexico, where 5 people were killed, three of them foreigners, during a music festival on Jan. 16, 2017. Stringer / AFP/Getty Images

Meanwhile, inside the club “three, four police [were] running, chasing someone, could've been staff or even crooks but I'm not sure,” said Escardo, who added that he saw at least three people who appeared to have been shot.

Marcos Vazquez was with his girlfriend at the nearby La Vaquita nightclub when he saw people running by.

The 29-year-old from El Paso, Texas, told NBC News that he ran into the bathroom and locked himself inside with eight other people. Five minutes later, they left and went outside and took a taxi away from the club.

The organizers described The BPM Festival as "an annual ten day and night electronic music festival." Sunday was its closing night.

"This global gathering of DJs, producers, revelers and industry professionals has become a must for any music lover with a discerning taste for quality electronic dance music," according to Thump, a music and culture channel for VICE.

A map showing Playa del Carmen, Mexico. Google Maps

Tourism is vitally important Playa del Carmen, which is located in the state of Quintana Roo on the Yucatan Peninsula. It had escaped much of the bloody violence that have plagued Mexico's western coastal tourists spots, such as Acapulco.