The Cairo Criminal Court also sent three others to 15 years in prison in the same case.
The court found that the convicts had joined the "Marsa Matrouh cell", which is affiliated to IS in Libya.
They were also found guilty of joining training camps in Libya and Syria, planning terrorist attacks in Egypt, possessing weapons, inciting violence and participating in killing of 21 Christians in Libya in 2015.
The sentencing came a day after the deadliest terrorist attack on worshippers at a mosque in Egypt's restive North Sinai region. The death toll in the attack today rose to 305.
The Egyptian security forces, meanwhile, have continued their air strikes against terrorists involved in the attack.
Army spokesperson Tamer el-Refai said in a statement that the Air Force destroyed a number of terrorists hideouts and the Army was conducting raids to eliminate terrorists.
Disclaimer: No Business Standard Journalist was involved in creation of this content