The deadly assault came just a day after security forces carried out two simultaneous raids on apartments in a crowded district in capital Cairo.
The suspected militants first opened fire at security force members, prompting them to respond, the ministry added on its official Facebook page. The firefight led to the death of both of the militants, according to the statement.
Five policemen, including three officers, were also injured in the shootout, he said.
The attack illustrates how hard it is for the government to crush a militant campaign that has withstood a four-year crackdown.
Nine suspected terrorists have been killed in a shootout in Egypt's third largest city Giza, home to the legendary Great Pyramids and the Sphinx. The five had in their possession different types of guns in various areas of Cairo including El Marg, Ain Shams and Al-Salam.
In July, 11 people affiliated to IS were arrested in a residential apartment located inside Imbaba, Giza, where police seized large amounts of explosives.
Egypt has battled fighters in Sinai for years, but the rebellion became far more deadly after the 2013 military removal of Mohamed Morsi. Hundred of security forces have been killed as well as hundreds of militants.
Terror attacks in Egypt used to focus on police and military men in North Sinai before spreading nationwide and targeting the Coptic minority as well, with majority claimed by a Sinai-based group loyal to the regional Islamic State (IS) militant group.
The officials said the militants were members of Hasm, a breakaway Brotherhood faction that has targeted police and army officers in Cairo over the past year in a series of brazen attacks.