CHARLESTON, S.C. — Emanuel AME Church swung open its doors for services Sunday, four days after a 21-year-old white man who told police he wanted “to start a race war” allegedly killed the pastor and eight congregants attending a Bible study in the church basement.

Hundreds lined up in the hot Charleston sun to climb the stairs to the sanctuary of “Mother Emanuel,” one of the country’s oldest African American churches and one with a rich history of resilience. The organist played and church bells chimed as the choir sang “Blessed Assurance.”

Worshipers from Charleston and across the country filled the pews and balcony of the church. Some watched the sermon from seats in the fellowship-hall basement — where the shooting occurred Wednesday.

“This is our house of worship,” said the Rev. Norvell Goff, presiding elder of the Edisto District of the State Conference of the AME Church, addressing the congregants. “The doors of the church are open, praise be to God.”

“No evildoer, no demon in hell or on Earth can close the doors of God’s church.”

Many in the pews fanned themselves furiously, beating back a thick heat and their fragile emotions. People fought tears, rocking back and forth. Some comforted each other in long embraces. Ushers passed out bottles of cold water. And above them all loomed the pastor’s usual seat, empty, covered by a black cloth.

In Emanuel AME’s nearly 200-year-old history, the congregation has withstood slavery, segregation, racially motivated laws to keep worshipers from meeting and fires set by angry, white mobs. But the massacre Wednesday of state Sen. Clementa C. Pinckney, who was the church’s pastor, and eight church members left many wondering how such a horrible tragedy could occur in a place they consider a safe haven.

“It has been tough, it’s been rough, and some of us have been downright angry. But through it all, God has sustained us and encouraged us,” Goff said. “When times of trouble come into our lives, how do we respond? Do we respond by being afraid? Or do we respond in faith?”

Goff encouraged the congregation to continue to pray and look to God for healing.

“The blood of the Emanuel Nine requires us to work for not only justice in this case, but for those living on the margins of life,” he said. “We must stay on the battlefield until there is no more fight to be fought.”

Reporters, he said, had asked him how some grieving family members who attended the bond hearing of suspect Dylann Roof could say they would forgive him. Roof, who was arrested Thursday in Shelby, N.C., about four hours away from the church, was charged with nine counts of murder and possessing a firearm in the commission of a violent crime.

The families, Goff said, were holding on to a strong faith that teaches them to love their neighbors. “God is our refuge and our strength,” Goff said. “We ought to put our hope and trust in God.”

Daniel E. Martin Jr., 52, who said his family has been on the membership rolls of Emanuel for more than 100 years, said the church would heal and grow stronger. “It’s painful and difficult, but if you know anything about the people of faith, Charlestonians, members of the church, you will understand when we come to church we receive the word of God.”

His wife, Reba Martin, 54, a steward in the church, said when she walked in the church Sunday, she thought she saw Pinckney. “Pastor was so tall,” she said. “I can almost see him standing there with all the people who sat next to him in the pulpit.”

Reba Martin said the congregation full of people who had come to share in the service was an answer to Pinckney’s dream of getting more people to come to church: “When pastor first came, our congregation was so small, he would say, ‘One day you will see the church full to the rafters.’ That happened today.”

On Saturday, Charleston police gave church leaders permission to open the church. Church leaders met in the basement, which police had cleaned, covering bullet holes.

“I was pleased when authorities made a phone call and said you can go back in Mother Emanuel,” Goff said. “The open doors of Emanuel on this Sunday sends a message to every demon in hell that no weapon formed against me shall prosper.”

Many members said they looked forward to the church opening its doors. Others were still hesitant.

“How do you bring yourself to a place where tragedy struck?” said Brandon Robinson, 26, minister of music of “Little Emanuel,” a sister church. “There is an opened wound. Someone lost a brother, a husband, a father, a sister and auntie.”

Before sunrise Sunday, sextons — keepers of the church — began clearing a path amid hundreds of flower bouquets left on the church steps by mourners. Some lit white votive candles and prayed. Others threaded long-stemmed red and pink roses through the bars of the church’s gate.

Police officers swept the church early in the morning and screened worshipers as they filed in. No backpacks were allowed in the building. At least half a dozen officers stood watch, sometimes passing out water and butterscotch candies to churchgoers.

People, shaken by the tragedy, stood looking up at the church’s white steeple and prayed.

“You have individuals across the country asking, ‘How could God allow something like this to happen?’ ” said the Rev. Branden Sweeper, 30, who was close friends with Pinckney. “Church is still the best place to be.”

“Mother Emanuel,” as members call the church founded in 1816, is one of the oldest and largest AME churches in the South. The white stucco church with towering steeples, wooden rafters and arched stained-glass windows sits in downtown Charleston on Calhoun Street. The church was the site where in 1822, Denmark Vesey, a freed slave, planned one of the biggest slave insurrections in U.S. history.

“When authorities were made aware of his plot, Vesey and a number of his followers were executed,” according to the book “African Methodism in South Carolina,” a collection of histories compiled by the AME Church.

The church was burned down by white crowds. “And even more strict regulations were imposed on Charleston’s Black Churches,” the book said. By 1834, all black churches were closed by state law. Some members of the church joined white churches, and “others continued the tradition of the African church by worshiping underground.” In 1865, Emanuel AME resurfaced with 3,000 members.

With the latest tragedy still looming large in the church Sunday, some members doubled over in grief, weeping for the victims.

“There they were in the house of the Lord studying your word, praying with one another, but the Devil also entered,” an elder said in a prayer Sunday. “And the devil was trying to take charge. But thanks be to God — hallelujah — that the devil cannot take control over your people, and the devil cannot take control of the church.”

Eartha Ugude drove eight hours Saturday from Port St. Lucie, Fla., compelled to be in the service. “I felt such a tremendous loss,” she said from her seat, 10 rows from the pulpit. “I felt helpless and tired — one more tragedy against our people.”

The shooting, she said, was cowardly. The gunman “sat amongst them.”

Goff preached that the members should not respond to the tragedy with fear. “Do we respond by being afraid? Or do we respond in faith?” Goff asked. “As for me and my household, we will serve the Lord, because it is by faith we are standing here this morning.”

Acknowledging the congregation has difficult days ahead, Goff said: “The only way evil can triumph is for good people to sit down and do nothing. We are children of God. We will march on to victory.”

The service ended with a prayer, “May the people of God say Amen.” Members who filed out of the church said they were encouraged by the sermon.

Marlene Coakley-Jenkins, whose sister Myra was killed in the church basement, said she was inspired.

“I think the message was powerful, positive and compassionate,” Coakley-Jenkins said on the church steps. “Everything the family needed at this particular time. It gave us strength and faith. It allowed us to have all the emotions that an experience like this might conjure and more.”

Someone asked her whether she was thinking of the shooter. “I pray at some point he finds God’s mercy,” she said. “God’s mercy is even there for him. We can’t afford to lose one soul on Earth. I am ready to forgive him. I have to because that would block so many blessings. Nothing grows positive out of hate.”

[This post has been updated.]