A Catholic adoption agency in Scotland has avoided a threat to its charitable status that could have closed the agency, following an appeals board's ruling that it may follow Church teaching against same-sex adoption.

"We are delighted and relieved that the threat hanging over us has been lifted," a spokesman for St. Margaret's Children and Family Care Society said, according to BBC News.

"Our only wish is to continue to do the good work for which we have been recognized by the authorities, of placing children in need of families with loving parents."

The adoption agency specializes in helping children in difficult circumstances find a home. It has been honored with national awards for its work.

The agency places a priority on adoptive parents who are Catholic and married for at least two years, BBC News reports.

Seeking to follow Catholic principles, it does not place children with same-sex couples.

After receiving a complaint from the National Secular Society, the Office of the Scottish Charity Regulator had reviewed the adoption society and ruled that its policies had a negative impact on same-sex and cohabiting couples and violated the Equality Act of 2010.

However, the Scottish Charity Appeals Panel has now overturned that decision, noting that the adoption agency provides a public benefit and ruling that it may continue adhering to Catholic teaching as it carries out its work.

Archbishop Philip Tartaglia of Glasgow, the president of the children's society, voiced gratitude for the appeals panel's "wise decision."

"It means that families who are ready to adopt can look forward to the future with a little more serenity, and children in great need can be placed into loving homes."

The adoption agency is partially funded by the Catholic Church, and several bishops are on its board of trustees.

Archbishop Tartaglia said the agency is "small" and "does great work for the wider community." The agency "helps transform the lives of some of the most vulnerable children in society."

"It would have been have been a great pity if it had been forced to close," he said.

The society has placed hundreds of babies and children with families since it was founded in 1955.

Almost all Catholic adoption agencies in the U.K. have already been forced to shut down or disaffiliate from their church sponsors due to the strict interpretation of anti-discrimination laws.

Last summer, hundreds of adoptive families and members of the community gathered at Glasgow's cathedral to support the adoption agency and commemorate its years of service.

Brian McGuigan, a member of the society's board, explained in a statement last June that "Saint Margaret's origins and identity are inseparable from the Catholic Church and her values and moral teaching in respect to marriage and the family."

"The ultimate irony is that apparently in the name of tolerance, societies such as Saint Margaret's are no longer to be tolerated," he said. "The reality is that the issue is not one about equality or diversity, but about freedom of religion and belief."