SOUSSE, Tunisia -- A young man pulled a Kalashnikov from a beach umbrella and sprayed gunfire at European sunbathers at a Tunisian resort, killing at least 39 people -- one of three deadly attacks Friday from Europe to North Africa to the Middle East that followed a call to violence by Islamic State extremists.

The shootings in the Tunisian resort of Sousse happened at about the same time as a bombing at a Shiite mosque in Kuwait and an attack on a U.S.-owned factory in France that included a beheading. It was unclear if the violence was linked but it came days after the IS militants urged their followers "to make Ramadan a month of calamities for the nonbelievers." In all, the assailants killed at least 65 people.

Gunman attacks tourists in Sousse, Tunisia

The SITE Intelligence Group reported later that the IS claimed credit for the Tunisia attack on its Twitter account and identified the gunman as Abu Yahya al-Qayrawani.

The attack in Tunisia, the country's worst ever, comes just months after the March 18 massacre at the national Bardo museum in Tunis that killed 22 people, again mostly tourists, and has called into question the newly elected government's ability to protect the country.

"Once again, cowardly and traitorous hands have struck Tunisia, targeting its security and that of its children and visitors," President Beji Caid Essebsi told reporters at the RIU Imperial Marhaba hotel, near the beach rampage site.

Essebsi promised "painful but necessary" measures, adding: "No country is safe from terrorism, and we need a global strategy of all democratic countries."

Injured people are treated in Tunisia

Rafik Chelli, the secretary of state of the Interior Ministry, told The Associated Press that the attack was carried out by a young student not previously known to authorities. At least 36 people were reported wounded in the shooting spree, which ended when the gunman was shot to death by police.

The Islamic State group claimed responsibility for the suicide bombing at the Shiite mosque in Kuwait City that killed at least 27 people and wounded scores of other worshippers at midday prayers -- the first such attack in the mostly quiet and relatively secure Gulf Arab nation in more than two decades.

In southeastern France, a man with ties to Islamic radicals rammed a car into a gas factory, touching off an explosion that injured two people. Authorities arriving at the site made a grisly discovery: the severed head of the driver's employer was found hanging at the plant entrance.

The suspect, Yassine Salhi, was seized by an alert firefighter, authorities said, and French President Francois Hollande said the attacker's intention had been to cause an explosion. A security alert for the southeast region was raised to its highest level for the next three days, and the U.S. Embassy in Paris warned American citizens to be vigilant.

Gunmen kill dozens in attack on Tunisia beach

In an audio recording released Tuesday, the Islamic State called on its supporters to increase attacks during Ramadan and "be keen on waging invasion in this eminent month and commit martyrdom."

In Britain, police said they were tightening security at major events after the attacks in France, Kuwait and Tunisia, including for the weekend events of Armed Forces Day and the Pride London gay and lesbian festival.

The attacks were condemned by the United Nations, the U.S., Israel and others.

"We stand with these nations as they respond to attacks on their soil today," the White House said. Pentagon spokesman Col. Steve Warren added it was "too soon to tell whether or not these various and far-flung attacks were co-ordinated centrally or whether they were coincidental."

The carnage in Tunisia began on the beach, where tourists described hearing what sounded like fireworks and then running for their lives when they realized it was gunfire. Video of the aftermath showed medics using beach chairs as stretchers to carry away people in swimsuits.

"He had a parasol in his hand. He went down to put it in the sand and then he took out his Kalashnikov and began shooting wildly," Chelli said of the gunman.

He then entered the pool area of the Imperial Marhaba hotel before moving inside, killing people as he went.

27 dead in attack in Tunisia

British tourist Gary Pine told AP he was on the beach with his wife around noon when heard the shooting. They shouted for their son to get out of the water, grabbed their bag and ran for the hotel. Their son told them he saw someone shot on the beach.

There was "sheer panic" at the hotel, Pine said. "There were a lot of concerned people, a few people in tears with panic and a few people -- older guests -- they'd turned their ankles or there was a few little minor injuries and nicks and scrapes."

Elizabeth O'Brien, an Irish tourist who was with her two sons, told Irish Radio she was on the beach when the shooting began.

"I thought, 'Oh my God. It sounds like gunfire,' so I just ran to the sea to my children and grabbed our things" before fleeing to their hotel room, she said.

The Health Ministry said the dead included Tunisians, British, Germans and Belgians, without giving a breakdown.

British Foreign Secretary Philip Hammond says at least five Britons were killed but expected to toll to rise because a high proportion of the dead were believed to be British.

Since overthrowing its secular dictator in 2011, Tunisia has been plagued by terrorist attacks, although only recently have they targeted the tourism sector, which makes up nearly 15 per cent of GDP.

"The Foreign Office will declare the summer effectively over for Tunisia, and it will destroy -- besides the lives taken -- the tens of thousands of livelihoods who depend on tourism for a living," said Simon Calder, a London-based travel commentator. Nearly half a million Britons visited Tunisia in 2014.

Attack in Tunisia

At a news conference at his office in the capital Tunis, Prime Minister Habib Essid said he would immediately close mosques outside the control of the ministry of religious affairs and call army reservists into active service and place them around the country.

"No mosque that does not confirm to the law will be tolerated," he said, referring to those that incite to terrorism.

The attacks are also a blow to Tunisia's image as a stable, democratic nation emerging from its revolution in 2011, said Jonathan Hill, a professor of Defence Studies at King's College in London.

"The terrorists are attacking Tunisia's reputation," he said. "Not just as a safe and welcoming destination for Western holidaymakers, but as the one real success story to emerge out of the Arab Spring."

International police agency Interpol offered investigative help in the wake of Friday's violence. Interpol Secretary-General Juergen Stock said the attacks "show the truly global dimension to current terrorist threats."

------

Schemm reported from Rabat, Morocco. Associated Press Writers Bouazza Ben Bouazza in Tunis, Jill Lawless and Greg Katz in London, Shawn Pogatchnik in Dublin and Angela Charlton in Paris contributed to this report.

------

This story has been corrected to reflect that authorities now say there was only one gunman, not two, and that the message from the Islamic State was an audio recording, not a video.