A boy in a back pew stared stoically ahead through most of the Sunday Mass at St. Ann’s Parish in Dorchester, where the family of the 8-year-old killed in the Boston Marathon bombings attends church.

But after Communion, his shoulders began to shake. He bowed his head and slowly brushed a tear from his eye, as if hoping no one would see. Without a word, an elderly woman a few feet away slipped him a packet of tissues.

At churches most directly affected­ by the bombings and their aftermath, congregants on Sunday mourned and comforted one another, taking refuge after a week of horrific violence in an hour or two of togetherness.

At St. Ann’s, the loss was intensely personal. At St. James Armenian Apostolic Church in Watertown, churchgoers were recovering from Friday’s shootout and daylong lock-down.

Two historic Back Bay churches, Old South Church and Trinity Church, could not even open their doors because of their proximity to the blast sites; both were within a blocked-off area where police were still gathering evidence.

So they accepted other congregations’ hospitality. The Church of the Covenant held a joint service with Old South, and Temple Israel, the city’s largest synagogue, opened its doors to Trinity for a service that drew close to 900.

“It feels like the right way to have a church service, extending community and love to neighbors regardless of exact beliefs,” said Dr. Phoebe Freer, a member of Trinity.

From pulpits across Greater Boston, clergy offered sermons on caring, kindness, and the power of community. At the Cathedral of the Holy Cross in the South End, Cardinal Sean P. O’Malley asked those gathered to answer the violence with love, not retribution aimed at followers of the suspects’ faith.

“The crimes of two young men must not be justification for prejudice against Muslims and against immigrants,” he said. “The Gospel is the antidote for the ‘eye for an eye, tooth for a tooth,’ mentality,” he said.

The main mosques in Boston and Cambridge were closed on Friday because of the manhunt for the second suspect. Both directed their members to an interfaith prayer service in Dorchester. The service had been planned for weeks, but it took on new meaning after the bombing.

“As Bostonians, we share the grief of the city,” said Imam William Suhaib Webb of the Islamic Society of Boston Cultural Center in Roxbury. “We’re equally appalled.”

Many Jewish Shabbat services were canceled Friday, as well, but on Saturday synagogues reopened.

Rabbi Andrew Vogel of Temple Sinai in Brookline said he focused his sermon on the week’s Torah portion, which included the command from ­Leviticus to “love your neighbor as yourself.”

At St. Ann’s, the midmorning Mass on Sunday was filled with bewilderment and tears, many from children. More than 500 people came to the brick-faced church to seek comfort and to pray for Martin Richard, his family, and all those injured in the bombings.

Denise Richard, Martin’s mother, and his younger sister, Jane, are still recovering from serious injuries.

“We weep for the last week,’’ the Rev. Sean M. Connor told parishioners. “If we are not changed for the better . . . then we’ve learned little or nothing.”

After the service, parishioners and visitors gathered in the sunshine out front, where tulips filled a grassy strip.

A young man with a goatee stood apart on the front steps, weeping inconsolably, his hand across his eyes.

A boy clutched his mother’s hand as she hugged another parishioner fiercely.

“We are here because we are a community,’’ said one man who attended the Mass but asked not to be named. “We will get through this.”

Miles away at Temple Israel, Trinity’s members received a warm welcome from Rabbi Ronne Friedman and synagogue leaders, who greeted worshipers as they entered the sanctuary. “We are thrilled beyond words that you are here,” Friedman said.

He received a standing ovation from the congregation, many of whom said they were moved by the gesture.

“It’s a very strange feeling to be separated from your church home,” said Arville Stephen, a psychotherapist and member of Trinity. “That area is so familiar to us as worshipers, to see it be the ground for so much pain and destruction — it’s hard to bear.”

“Now when I hear ‘valley of the shadow of death,’ I’m going to think of the canyon of Boylston Street,” David McIntosh, a member, said afterward.

Trinity’s music director, Richard Webster, who finished Monday’s Marathon minutes before the bombs exploded, directed a choir whose members often sang through tears.

“I’ve been working with church music for over 40 years,” Webster said. “This was one of the holiest services I’ve ever been a part of.”

At the Church of the Covenant, the Rev. Rob Mark said he hoped that Boston, though scarred, would emerge as a more welcoming place.

“May this be our invitation as people of faith in the midst of the city of Boston to conspire together to tell a different narrative to our world — not one of violence, profiling, or revenge but one of selfless love, compassion, and hope,” he said.

Quoting from a sign made by Martin Richard, captured in a now-iconic photograph, he added: “A narrative of no more hurting people.”

The Rev. Nancy S. Taylor, Old South’s senior minister, pointed to the biblical teaching to give thanks in all circumstances. Expressing gratitude for good Samaritans, doctors, nurses, and police, she drew smiles and applause by expanding her list.

“I give God thanks for the Boston Red Sox, for David Ortiz speaking from the heart,” she said. “I give God thanks for Neil Diamond and ‘Sweet Caroline.’ I give God thanks for the New York Yankees.”

She said she was thankful to the congregation, too, “for not allowing the darkness to swallow the light.”

After the service, some worshipers walked to the corner of Berkeley and Boylston streets to join an interfaith gathering. Hundreds stood shoulder-to-shoulder before the crime scene barricades, gazing at the makeshift memorial of flowers, balloons, and American flags.

A group of about 30 friends, who were not affiliated with the worshipers, wore T-shirts emblazoned with “Do you want a hug?”

They delivered just that to anyone who said yes.

“Only love can repair all the damage people did to our city,” said Tania DeAngelis of Medford, who organized the hugging brigade.

In Watertown, St. James’s wooden pews were filled.

“What a week we had this past week. All of us,” said the Rev. Arakel Aljalian, who spent Friday making coffee for police stalking suspect Dzhokhar Tsarnaev.

And the Rev. Laura Everett of the Massachusetts Council of Churches, the guest preacher, noted that in the hours of the lock-down, trees began to bud.

“We step outside with the sky a deep headstrong blue to go to church, to drive to the grocery store, to go to school or work,” she said. “This is what the living do.”

The message resonated with Pam Talanian, a parishioner from Milton.

“This is our home and sanctuary,” she said. “I felt such freedom driving down Mount Auburn Street today.”

“Life goes on; we have to take care of each other,” she said.

Kathy McCabe and Joshua Miller of the Globe staff and ­correspondents Derek Anderson and Matt Rocheleau contributed to this report.

Correction: Because of a reporting error, an earlier version of this story incorrectly rendered a quote from Cardinal Sean P. O’Malley. O’Malley said, in part, “The crimes of the two young men must not be the justification for prejudice against Muslims and against immigrants.’’