Four glowing white pillar candles illuminated photographs of the people killed in bombing-connected violence in the Boston area last week as the city sought comfort in religious services on the first Sunday after the blasts plunged the community into days of chaos.

The photographs showing the faces of 8-year-old Martin Richard, 23-year-old Lu Lingzi, 29-year-old Krystle Campbell and 26-year-old Sean Collier, a police officer at the Massachusetts Institute of Technology, were propped up on the altar at Boston’s Cathedral of the Holy Cross, where Roman Catholic Cardinal Sean Patrick O’Malley spoke about the city’s pain and looked ahead to its spiritual recovery.

“Everyone has been profoundly affected by this wanton violence and destruction inflicted upon our community by two young men unknown to all of us,” said O’Malley, speaking to a crowd of mourners that included Boston Police Commissioner Edward Davis, who sat in the front row of the cavernous cathedral with other elected officials. “It’s very difficult to understand what was going on in their heads. What demons were operating, what ideologies or politics, or the perversions of their religion.”

Two Muslim brothers from Russia, 19-year-old Dzhokhar Tsarnaev and his 26-year-old brother, Tamerlan, are suspected in Monday’s Boston Marathon bombings. Their motive remains unclear. The older brother was killed during a getaway attempt, and the younger brother was captured Friday night after a gunfight with police and remains in a hospital.

Along the barricade that has become a shrine near the marathon finish line, hundreds of people sang hymns and prayed beneath a brilliant blue sky.

“Guide my feet while I run this race,” they sang.

Bouquets of flowers, small white crosses and American flags are piled at the makeshift memorial, where people have been gathering to pay their respects since the explosions.

Susan Ackley, a priest at the Emmanuel Episcopal Church a few blocks from the blast site, said religious leaders had visited the area “to clear the air and to bless it.” She encouraged people to forgive the perpetrators, noting that her congregation had prayed for the suspect who had been killed and the other who remains in police custody.

“Instantaneous forgiveness, I think, is impossible,” she said. “That’s not what needs to happen. But I think it is the role of the churches and the synagogues to try to hold this community of human beings together.”

O’Malley echoed that sentiment, exhorting the congregation to keep the spirit of community generosity alive — and to spread love, not hate.

“We must be people of reconciliation, not revenge,” he said. “The crimes of two young men must not be the justification for prejudice against Muslims or against immigrants.”

Kelly McKernan, who lives just a few blocks from the bombing site, was crying as she stood outside the cathedral, where people were hugging on the sidewalk.

“I hope we can all heal and move forward,” she said. “And obviously, the Mass today was a first step for us in that direction.”

Because it is within the bombing crime scene, Boston’s historic Trinity Episcopal Church could not host services Sunday. But the congregation was invited by Temple Israel to worship at its synagogue instead.

The FBI allowed church officials to enter the darkened church Saturday to gather the priests’ robes and the wine and bread.

The temple isn’t far from the hospital where the younger bombing suspect was being treated.

At least one man wore his blue Boston Marathon jacket with its gold unicorn symbol embroidered on the back.

At the synagogue, Trinity’s Rev. Samuel T. Lloyd III offered a prayer for “those who must rebuild their lives without the legs that they ran and walked on last week.”

“So where is God when the terrorists do their work?” Lloyd asked. “God is there, holding us and sustaining us. God is in the pain the victims are suffering, and the healing that will go on. God is with us as we try still to build a just world: a world where there will not be terrorists doing their terrible damage.”