The National Secular Society said the ruling "kicks a hole right through the Equality Act".
St Margaret's Children and Family Care Society in Glasgow was warned in a direction by the charity regulator last year that it could lose its charitable status unless it included same-sex couples.
The ruling was overturned on appeal to the Scottish Charity Appeals Panel (SCAP), the Catholic Church in Scotland said.
Terry Sanderson, president of the National Secular Society, said: "This ruling makes some highly dubious claims that need to be tested. It appears to widen the grounds on which religious groups can discriminate against gay people and make it possible to argue that because an organisation has a religious affiliation it can still qualify for charitable status even if it doesn't comply with the Equality Act."
He added: "In effect charities will be able to use taxpayers' money to discriminate against gay people."
The Office of the Scottish Charity Regulator looked at the practices of the charity after a complaint from the National Secular Society and in a report last year, found it was operating in breach of the Equality Act 2010.
St Margaret's gave greater priority to prospective adoptive parents who are a couple, Catholic, married for at least two years and who wish to adopt within the framework of a Catholic faith, the report said.
Lower priority was given to people married less than two years, couples in civil partner-ships, single people and married couples who do not wish to adopt within the Roman Catholic faith.
The regulator said marriage was not available to same-sex couples and that its policy constituted direct discrimination.
It told St Margaret's to amend its procedures, or risk losing its charitable status - a view confirmed in a subsequent review.
But St Margaret's took an appeal to the SCAP, which decided in favour of the adoption agency, the Catholic Church said.
A report on its website after an SCAP hearing in Edinburgh said that forcing the charity to close "would result in a loss to the community served by the appellant and when compared with the discrimination comp-lained of the decision is a disprop-ortionate regulatory measure."
St Margaret's president Archbishop Philip Tartaglia, president of St Margaret's, said: "It would have been have been a great pity if it had been forced to close."