The assault in the Red Sea resort of Hurghada came hours after a shooting near famous pyramids outside Cairo killed five policemen.
The motive behind the stabbing was unclear and the Interior Ministry said the attacker was arrested immediately.
A security official said the attacker, a man in his 20s dressed in a black T-shirt and jeans, wielded a knife and targeted foreigners.
Without taking any blame for what appears to be a major security breach, the Interior Ministry said the attacker had got into the hotel by swimming from a nearby beach.
No group claimed responsibility for killing the five police officers but it bore the hallmarks of a smaller Islamic militant group known as Hasm that has been behind similar shootings.
The attacker in Hurghada stabbed the tourists in the face, neck and feet, according to the security official.
Two German tourists died of their wounds while four others were hurt, including citizens of Ukraine and the Czech Republic, the official said.
In Germany, the foreign ministry said it "cannot rule out" that German citizens were among the victims but stressed that it does not have that information.
Gunmen riding on a motorcycle opened fire on a security vehicle patrolling a Giza village, killing the five policemen, the Interior Ministry and officials said.
It has claimed responsibility for drive-by shootings and attacks that targeted police, military, judges and pro-government figures in the past.