The motive for the attack is still under investigation, the ministry said, adding that the attacker had swum from a nearby public beach to access the holiday resort in Hurghada, some 400 km (250 miles) south of Cairo, Reuters said.
He was arrested.
Security and hospital sources said two Ukrainian women were killed. Other victims were taken to hospital. Their nationalities were not immediately known.
Read alsoEgypt declares state of emergency after deadly church attacks - BBCThe head of the consular department of Ukraine's foreign ministry, Vasil Kyrylych, declined comment pending official information from Egypt.
Egypt's security forces are fighting an Islamist insurgency in the Sinai Peninsula and militants have carried out attacks in the past on the tourism industry.
In January 2016, two assailants armed with a gun, a knife and a suicide belt landed on the beach of a hotel in Hurghada, wounding two foreign tourists, security sources said.