Judicial sources said the man who had swum ashore from a public beach in Hurghada to carry out Friday's attack confessed to sharing the ideology of the Islamic State jihadist group, although there was no IS claim of responsibility.
The sources said the suspect is a 28-year-old from Kafr al-Sheikh province in the Nile Delta, north of Cairo.
The streets of Hurghada were being heavily patrolled and security stepped up outside hotels on Saturday.
"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."
After initial confusion over the nationality of the women killed, Berlin on Saturday said they were both German nationals, rather than Ukrainians as earlier reported.
"I am very upset by this cowardly crime, my condolences to the families of the victims," German Foreign Minister Sigmar Gabriel said.
Among the four others wounded were two Armenian women and a woman from the Czech Republic, according to authorities in those countries.
It was not the first attack in Hurghada. In January 2016, three tourists were wounded in a stabbing assault in the resort by two assailants with apparent IS sympathies.
In Tunisia, IS claimed a beach attack in June 2015 when a student armed with a Kalashnikov assault rifle and grenades went on a rampage near the Mediterranean resort of Sousse killing 38 holidaymakers, 30 of them Britons, before being shot dead by police.
Hurghada is one of Egypt's most popular beach resorts, especially with Ukrainians and other European tourists.
Egyptian authorities say they have boosted security at the country's tourist sites, as the industry provides the Arab world's most populous country with much-needed revenues.
An IS bombing of a Russian airliner carrying holidaymakers from a resort in the south of the Sinai Peninsula in 2015 killed all 224 people on board and decimated the country's tourism sector.
Russia suspended all flights to Egypt in response and has yet to resume them.
IS has been waging a deadly insurgency concentrated in the north of the Sinai that has killed hundreds of policemen and soldiers.
Police, Copts also targeted
Also on Friday, unknown assailants shot dead five policemen just south of Cairo, in the latest of a series of attacks targeting Egypt's security forces.
The ministry said three gunmen opened fire on a police car and then fled, killing an officer, three conscripts and a police employee.
As with the beach stabbing, there has not yet been any claim of responsibility for the attack.
The killings came as police and the army said they were closing in on militants and jihadists following a spate of deadly attacks in the Nile Valley and the Sinai Peninsula.
Egypt has struggled to quell IS jihadists based in the Sinai and smaller militant groups in the mainland since the military overthrew Islamist president Mohamed Morsi in 2013 and cracked down on his supporters.
While smaller groups such as the Hasam militant movement have mostly targeted policemen and government officials, IS has also attacked foreign tourists and Egypt's Coptic Christian minority.
Dozens of Christians have been killed in church bombings and shootings since last December in attacks claimed by IS.
The jihadists have threatened to carry out further attacks on Christians, who make up about 10 percent of Egypt's 90 million people.
On Thursday, churches in Egypt said they were suspending some activities such as conferences and religious trips for three weeks over security concerns.