A man stabbed two tourists to death and injured four others at the Red Sea holiday resort town of Hurghada on Friday, in what officials said was a likely "Islamic State" (IS) inspired attack on foreigners.

The two killed were female tourists from Germany, the German Foreign Ministry confirmed on Saturday. It added the attacker intended to target foreigners.

"From all we have gathered, the attack was meant to target foreign tourists - an especially perfidious and criminal act that leaves us sad, shocked and angry," the Foreign Ministry said.

The knifeman swam to the hotel from a public beach, Egyptian authorities said. He then killed the two women and wounded two other tourists at the Zahabia hotel before moving on to a neighboring beach to attack at least two more people at the Sunny Days El Palacio resort.

Read more: As tourists become terror targets, travellers rethink their plans

'Not after Egyptians'

"He had a knife with him and stabbed each of them three times in the chest. They died on the beach," the security manager at El Palacio hotel, Saud Abdelaziz, told Reuters. "He jumped a wall between the hotels and swam to the other beach."

Workers and security personnel at the El Palacio resort stopped and tied up the knifeman who was taken into police custody.

"I was sitting down in my shop when we heard people shouting. We ran outside and heard that someone had swum to the next door hotel and was attacking foreigners," said Rafic Rushdi, the owner of a hotel shop. "After killing two women, he ran towards our hotel. He was shouting that he was not after Egyptians, and some Egyptians intervened to stop him."

The security presence was beefed up on Saturday in Hurghada, a popular tourist destination for Europeans.

Workers and security at the hotel detained the man who carried out the knife attacks.

Possible 'Islamic State' links

The motive for the attack is still under investigation, but it appeared to be inspired by IS calls to attack foreigners and Coptic Christians.

Security sources in Egypt said the assailant had been identified as a 28-year-old university graduate from the Nile Delta province, north of Cairo.

"He communicated with the organization via internet and was given the task of attacking foreign tourists on Hurghada beaches," a security source told German dpa news agency.

Another source told AFP news agency that the man had confessed to sharing IS ideology.

There has been no claim of responsibilty from IS.

Tourists in Hurghada have been previously targeted in attacks. In January 2016, three tourists were also injured in a similar knife attack in the resort city. That attack was carried out by two assailants with apparent IS sympathies.

Policemen killed

Friday's attack came only a few hours after five policemen were shot dead in Cairo's twin city of Giza, near the city's famed pyramids. No group claimed credit for that attack, which shared similar characteristics to others carried out by the shadowy group Hasm.

Police believe the group is an offshoot of the banned Muslim Brotherhood, whose leader Mohamed Morsi was ousted as president in a 2013 military coup.

A typical beach in Hurghada.

The Muslim Brotherhood is the world's oldest political Islamist movement, but most experts do not consider it a terrorist organization or believe it has ties to IS.

However, the Egyptian government and some conservative Arab monarchies consider the Muslim Brotherhood to be a political rival and have labeled it a terror organization.

Jihadist danger

Jihadist insurgents have carried out a number of attacks in Egypt since the 2013 military ouster of Morsi, with the violence concentrated in the northern Sinai Peninsula. There, the insurgency is led by an IS affiliate that regularly targets security services and is believed to have orchestrated the bombing of a Russian airliner in 2015 that killed more than 200 people, mostly tourists.

IS has also targeted Egypt's Coptic Christian population several times over the past year, killing scores of worshippers in bombings and shootings.

Read more: Sinai attack kills at least 26 Egyptian soldiers

The attack in Hurghada marks another blow to Egypt's struggling tourism industry, which employs millions of people and is a major source of foreign currency.

The once vibrant tourism industry has suffered since the 2011 Arab Spring protests and subsequent instability in the Arab world's most populous state.

cw/jbh/rt (Reuters, AFP, dpa, AP)