An evangelical fostering agency is planning to appeal to the Supreme Court to defend its right to place children only with heterosexual Christian married couples.
Ofsted downgraded the rating of Cornerstone (North East) Adoption and Fostering Service from "good" to "requires improvement" on the grounds that its sexual conduct policy was unlawful.
Paragraph 10 of its code of conduct requires that carers "set a high standard in personal morality which recognises that God's gift of sexual intercourse is to be enjoyed exclusively within Christian marriage", and that they "abstain from all sexual sins including immodesty, the viewing of pornography, fornication, adultery, cohabitation, homosexual behaviour and wilful violation of your birth sex".
Earlier this year, the High Court said Cornerstone had the legal right to work exclusively with Christian carers.
It asserted nonetheless that the adoption agency could not compel carers to live by paragraph 10 of the code of conduct.
Cornerstone, supported by The Christian Institute, argued that the High Court judgment was contradictory and sought to challenge this part of the ruling.
On Friday, the Court of Appeal upheld the High Court's verdict both in defending Cornerstone's right to recruit Christian carers, but also in taking exception to the requirement that they be in a heterosexual Christian marriage.
Lord Justice Peter Jackson said in the written judgment that he did not accept Cornerstone's claim that this was "legally contradictory".
"The difficulty with this logic is that it equates religious discrimination with sexual orientation discrimination in all circumstances when that is something that Parliament has not done," he said.
"Each protected characteristic has a quality of its own and the consequences of discrimination upon individuals and upon society as a whole will differ according to the context.
"Parliament has, speaking broadly, chosen to give priority to religious faith in a private context but to give priority to sexual orientation where public services are concerned – always subject to considerations of proportionality in the individual case.
"If Cornerstone's argument were correct, it could take advantage of the parts of the legislation that protect it and ignore the parts that protect others."
He added, "The result of Ofsted's stance, upheld by the Judge, is that Cornerstone's exclusionary recruitment policy is untouched, except as regards one aspect of paragraph 10 of its Code of Conduct.
"This outcome represents a quandary for Cornerstone but I do not accept that it is legally contradictory. It instead represents Parliament's attitude in principle to reconciling the two particular protected characteristics that are engaged."
Cornerstone CEO Pam Birtle said trustees were unanimous in their desire to challenge the decision, and an application to appeal to the Supreme Court has already been lodged.
"We're naturally disappointed that the Court of Appeal did not accept our argument that it is not the job of the courts to define what an evangelical is. But we know that by bringing this legal action we have already won more than we have lost," she said.
She added, "We are convinced that equality law protects our ability to operate in a distinctively evangelical way. For the law to do any less would be a breach of human rights and a denial of the values of a liberal democracy."
The Christian Institute's Deputy Director for Public Affairs, Simon Calvert, said the courts were effectively allowing Ofsted to "re-write" the definition of 'evangelical'.
He called today's verdict a "shocking defence of state overreach in religious matters" that "fundamentally misunderstands the nature of Christianity".
"It's right to fight discrimination. And evangelical Christians, though much maligned, have a good track record of welcoming people marginalised by the rest of society," he said.
"But the law and language of discrimination is in danger of being distorted beyond recognition. What the court has done today, in the name of opposing discrimination, is actually to support discrimination by a powerful state regulator against a small voluntary group.
"The Christian Institute has supported Cornerstone as it has sought to defend itself. All it wants to do is find homes for hard to place children by bringing evangelical carers into the system. Is that such a bad thing?"
Mr Calvert said he hoped the Supreme Court would "strike a fairer balance of competing rights".
"No gay carers were ever discriminated against by Cornerstone so this ruling does not in any sense 'right a wrong'. Instead, Cornerstone is being punished for holding the 'wrong beliefs'. Even worse, it is being told what it should believe instead. This is not what equality and human rights law are meant to be about," he said.