STAFFORD, Texas — Sabika Sheikh was a world away from close family when a gunman shot and killed her and nine other people at Santa Fe High School last week.

On Sunday, thousands turned out at a Houston-area mosque to briefly take part in a traditional Muslim funeral prayer for Sabika, 17, an exchange student, and to send their "sister" home to Pakistan.

"This is a tragedy that has touched every heart, every soul throughout this land and Pakistan," said Aisha Farooqui, consul general of the Pakistani consulate in Houston.

Across town and in nearby communities, worshipers turned to their faith for comfort and, for some, to find reasons for why their town became the latest to lose children and teachers in a school shooting.

"Each and every day, many people are being born, and each and every day many people die," Imam Taquir Shaikh said at Sabireen mosque. "God says — almighty Allah — this is to test us to see who among us has the best conduct."

The service, organized by the Islamic Society of Greater Houston, was opened to all so the public could serve as the family that isn't with Sabika now.

Sabika was just a few weeks from returning home to Karachi, Pakistan, when the gunman opened fire on her classroom. Dimitrios Pagourtzis, 17, is facing capital murder charges in the shootings. Police say he was armed with a shotgun and a revolver that belonged to his father.

Abdul Aziz Sheikh, the father of Sabika Sheikh, a victim of a shooting at a Texas high school, shows a picture of his daughter Saturday in Karachi, Pakistan. Fareed Khan / AP

Mourners, many from the Pakistani community in the area but also from other cultures and faiths, filled the main prayer hall and another prayer area for women at the mosque.

Others packed onto a covered patio where prayer rugs had been placed, and the service could be seen on televisions. An estimated 3,000 mourners, who came out despite despite the afternoon heat and humidity, spilled onto the adjoining playground and lawn.

In the Muslim tradition, Sabika's body was briefly brought to the mosque at Brand Lane Islamic Center for the janazah, a funeral prayer.

The prayer was said for her but also for "everyone suffering," Shaikh said. The names of each of the 10 victims also were recited.

The Cogburn family, which had hosted Sabika, attended the service and told mourners of the loving young girl who had embraced American culture and taught them so much about her own that they had been fasting for Ramadan — the month of fasting practiced by Muslims — with her.

Jason Cogburn, right, speaks as his wife, Joleen, left, and daughter, Jaelyn, far left, listen during a funeral for Pakistani exchange student Sabika Sheikh, who was killed in the Santa Fe High School shooting, during a service Sunday at the Brand Lane Islamic Center in Stafford, Texas. David J. Phillip / AP

Jaelyn Cogburn, 15, said that she had bonded with Sabika, who lived with her family in Santa Fe, because, like her, she knew few people at Santa Fe High School. Jaelyn had just begun her first year at public school after having being home-schooled.

Jaelyn told the mourners that the two had grown close and that on a recent night she was crying while driving because she knew Sabika would be returning to Pakistan.

"She leaned in and said, 'I love you and I miss you.' Even though we were always together, I don't know why she said she'd miss me," Jaelyn said through tears.

Joleen Cogburn, Jaelyn's mother, wore a crimson embroidered shawl covering her hair and head, which Sabika had given her on Mother's Day, she said, as she became increasingly choked up.

Cogburn said Sabika once told her: "I want to learn the American culture, and I want America to learn the Pakistan culture, and I want us to come together and unite."

Sabika brought love with her, said Joleen Cogburn's husband, Jason, who added that the family would "carry on that tradition of love that she brought from Pakistan."

"The root of our issue is love, because when people love each other, these kinds of things don't happen," Jason Cogburn said.

Cross for Texas shooting victim Sabika Sheikh put out by Crosses for Losses at Santa Fe High School.

Back at the school, members of a charity called Crosses for Losses planted 10 white crosses on the campus for the 10 shooting victims, including one for Sheikh, although she was a Muslim.

Earlier Sunday, nine seniors walked down the aisle at Arcadia Baptist Church wearing their graduation gowns and mortar boards as "Pomp and Circumstance" played over the sound system.

The service, attended by Texas Gov. Greg Abbott, was supposed to have recognized seniors in the congregation, but the focus shifted to the classmates and teachers who were killed.

Interim pastor Jerl Watkins told the congregation that the teaching of Christ was "that as long as we live on this Earth, we are going to have trouble, we are going to face tragedy, but if a person is in Christ, then he can have a peace in spite of the tragedies."

Santa Fe High School graduates bow their heads in prayer during a baccalaureate service Sunday in Santa Fe, Texas. David J. Phillip / AP

"We live in a fallen, sinful world, and therefore no matter who we are, no matter how good we are and how bad we are, we are going to have problems," he said. "We are going to suffer and be affected by the sins in this world."

Suzanne Gamboa reported from Stafford, Texas, and Phil McCausland from New York.