Three people were shot and killed and two others were wounded Sunday when gunmen opened fire at a popular Mexican beach resort that was crowded with tourists, officials said.

The gunmen attacked the group at the entrance to Playa Pamilla in the Los Cabos tourist region at the southern tip of the Baja California peninsula.

Mexican and foreign tourists were sunbathing on the beach when the bullets started flying.

"We heard the shots and just ran to get somewhere safe. It was automatic weapons fire," a tourist told the BBC.

The beach was evacuated as police investigate the possible motive.

Southern Baja California has seen a surge in violence this year, though mostly outside tourist areas. Analysts blame much of the bloodshed on fighting among factions in the Sinaloa drug cartel and also clashes with the rival Jalisco New Generation cartel.

The Associated Press contributed to this report.