Berlin has confirmed that two women killed by a knifeman “looking for foreigners” in the Egyptian resort of Hurghada were German nationals.

“We can now sadly confirm that two German tourists died in the attack at Hurghada,” a foreign ministry statement said. Initial reports had indicated that the women were Ukrainian.

The attacker killed the women and injured two others at the Zahabia hotel, according to officials and eyewitnesses who spoke to Reuters.

Saud Abdelaziz, security manager at the nearby Sunny Days El Palacio hotel, told the news agency that the attacker “had a knife with him and stabbed each of them three times in the chest. They died on the beach”.

He then jumped over a wall and swam to a beach at the El Palacio, attacking another two Europeans before being overpowered by staff members and detained.

An eyewitness at the Zahabia told Reuters the attacker “was looking for foreigners and he didn’t want any Egyptians”.

Abdelaziz identified the injured as two Czechs and two Armenians, but there are claims a Russian national was among the victims as well.

A senior official at the Egyptian interior ministry told AFP that the authorities “don’t know [the attacker’s] motives yet, he could be crazy or perturbed – it’s too early to tell”.

Regional media citing “security sources” claim to have identified the attacker as a 28-year-old graduate of the Faculty of Commerce at al-Azhar University, originally from the town of Qaleen in Kafr al-Sheikh – but officials have yet to publicly confirm the man’s identity.

In January 2016, three European tourists in Hurghada were wounded in a stabbing assault by two assailants with apparent Islamic State sympathies, but there was no immediate claim of responsibility for Friday’s stabbing.

AFP contributed to this report.