They said worshippers shut the church's iron gate to prevent the assailant entering and killing more people in the attack which lasted up to 20 minutes, with another 10 minutes passing before police shot and wounded the assailant.
A brave 53-year-old resident pounced on the gunman as he reloaded his automatic rifle in a move which likely also saved dozens of lives in the southern suburb of Helwan, said the witnesses.
Courageous residents pelted the assailant with rocks and soda cans as he walked away from the church, occasionally pausing to fire warning shots from his AK-47 rifle.
The attack began at around 10.30am when Mass at the Mar Mina church had just finished and some worshippers were already heading home.
Magdy Adel, a 65-year-old Christian who runs a store near the church, sheltered five worshippers - three elderly women, one elderly man and a middle-aged woman - who took cover in his shop. He pulled down the store's shutters and hid on the pavement behind a car to keep an eye on the attacker.
"The terrorist was very agitated when they closed the church's iron gate and he could not go inside," he said. "He had a lot of ammunition and kept shooting at the gate, killing some people inside."
Another witness, Mustafa Mahmoud, was on the street a short distance from the church when the gunman opened fire. He first thought the gunman was a plainclothes policeman assigned to guard the church.
"His first victim was a policeman guarding the church. He shot him but did not instantly kill him. A young man who rushed out from the church was killed right away. When a second policeman emerged, he shot him in the leg and he was dragged back inside the church by worshippers to keep him out of harm's way."
"Later, the terrorist finished off the first policemen with a few shots to the chest," said Mr Mahmoud, a 39-year-old father of two.
The Christian owner of a store that sells wood coffins was shot dead, and his wife was shot dead too when she stormed out of the church to check on him.
"Their daughter was shot and wounded," added Mr Mahmoud.
He said the gunman later moved away to look for the motorbike he rode to the site, but residents had hidden it to deny him a getaway. "He still had ample chance to get away but seemed not to want to. He was either suicidal or deranged," Mr Mahmoud said.
He was among dozens of men that pursued the gunman, taking shelter behind cars and inside building entrances to avoid being shot. When the gunman was pinned to the ground by Salah el-Mougi, a 53-year-old driver, they rushed toward the assailant."
One social media video showed the final minutes before the gunman was shot. Wounded in the leg and shoulder, he sat up and appeared to be reloading his rifle when Mr el-Mougi pounced on his back.
"That was divine luck, he would have shot me had I hesitated for a second," said Mr el-Mougi, adding "I wanted to prevent him from using a suicide belt or explosives."
IS's local affiliate is spearheading an insurgency in Egypt's Sinai Peninsula that has grown in sophistication and brutality in recent months.
IS militants have targeted Egypt's Coptic Christian minority since December last year, with church bombings that killed more than 100 and wounded scores.
Three people were hurt when a large mob of Muslims shouting anti-Christian slogans stormed an unlicensed church south of Cairo on December 22, assaulting worshippers and destroying furniture and fittings.
Christians make up about 10% of Egypt's population. They have long complained of discrimination in the Muslim-majority nation and that authorities don't do enough to protect them.