Pech said a lone gunman apparently entered the nightclub and began to exchange fire with another person inside. Festival security personnel tried to stop the shooting and came under fire

Receive the latest national-international updates in your inbox

Police guard the entrance of the Blue Parrot nightclub in Playa del Carmen, Mexico, Monday, Jan. 16, 2017. A deadly shooting occurred in the early morning hours outside the nightclub while it was hosting part of the BPM electronic music festival, according to police.

A shooting attack at an electronic music festival in Mexico's Caribbean coast resort of Playa del Carmen on Monday left five people dead, including two Canadians, an Italian and a Colombian, authorities said.

The attorney general of Quintana Roo state said that several of the dead appear to have been part of the security detail at the 10-day BPM electronic music festival.

Miguel Angel Pech said the shooting occurred about 2:30 a.m. at the Blue Parrot nightclub, one of the BPM Festival's venues in Playa del Carmen, just south of Cancun.

Pech said a lone gunman apparently entered the nightclub and began to exchange fire with another person inside. Festival security personnel tried to stop the shooting and came under fire.

He said three people had been detained nearby, but it was unclear if they had been involved in the shooting.

Rodolfo Del Angel, director of police in the state of Quintana Roo, told the Milenio TV station that he shooting was the result of "a disagreement between people inside" the nightclub and said security guards had come under fire when they tried to contain the dispute.

The BPM Festival posted a statement saying four people had been killed and 12 injured in an attack that involved "a lone shooter."

BPM wrote that "the violence began on 12th street in front of the club and three members of the BPM security team were among those whose lives were lost while trying to protect patrons inside the venue."

Playa del Carmen has largely been spared the violence that has hit other parts of Mexico.

Canadian officials could not immediately confirm if any of their citizens were among the victims in the shooting.