The Coptic Church said the gunman first shot at a Christian-owned shop 4 km (3 miles) away, killing two people, before proceeding to the Mar Mina church in the southern Cairo suburb of Helwan.
State television reported the second attacker was captured after fleeing the scene. At least nine people were killed, an official said, in the latest violence targeting Egypt's Christian minority. Two bombs were defused near the church.
Five security guards were also wounded in the rampage outside the church south of the capital Cairo before a gunman was shot dead as he tried to storm the building.
Authorities in Egypt reported at least nine people dead after two gunmen attacked a church south of the capital on Friday.
They have increasingly targeted civilians as attacks on the security forces have become more hard.More news: New Year's Eve 2018: Watch Mariah Carey, Camila Cabello, BTS and More
A video circulating on social media after Friday's attack apparently showed the gunman lying on the ground with his face covered in blood.
Investigators have identified the gunman, it said, adding that he had carried out several attacks since previous year. "There was more than one attacker", Mohammed Hussein Abdelhadi, who lives close to the church, told Reuters.
Christians, who make up about 10 percent of Egypt's population, have long complained of discrimination in the Muslim-majority nation, and say authorities have often failed to protect them from sectarian attacks.
The attack on the church came a day after six Egyptian soldiers were killed in a roadside bombing in the Sinai.