A Catholic adoption agency has been warned that it could lose its charitable status over its refusal to place children with same-sex couples.
The Scottish Charity regulator said St Margaret's Children and Family Care Society provides a valuable service.
But the watchdog said it believed its current practice was unlawful. It has now given the society three months to change its procedures.
The Glasgow charity said it was talking to legal advisors about the matter.
The ruling from the regulator follows a complaint from the National Secular Society about St Margaret's statement that it would place children with parents who have been married for at least two years.
'Duty to act'
The Scottish Charity Regulator's head of registration, Martin Tyson, said: 'We acknowledge the valuable service provided by this charity, but the fact is that all charities must comply with the law, including the Equality Act 2010.
"Where we find this is not the case, we have a duty to act.
'We have carefully considered the details of this case, and the legal position is clear - the charity must take steps so that it does not discriminate unlawfully and can pass the charity test."
He said this was a "complex" case and the regulator had "discussed matters at great length with the charity's trustees".
Mr Tyson added: "We hope that the charity will respond positively and take the necessary action so that it remains in the Scottish Charity Register."
The regulator has issued a direction to St Margaret's, instructing it to amend its procedures and assessment criteria to meet the requirements of the Equality Act.
It has until 22 April 2013 to do so or risk losing its charitable status.
A spokesman for the Catholic Church said it had been informed of the regulator's findings.
He added: "We will fully examine the contents of their determination and take appropriate legal counsel before responding."
Education Secretary Mike Russell said he was "disappointed" by the regulator's decision.
"We do not believe that this outcome is in the best interests of the children St Margaret's helps, who are in need of a safe and loving family home," he said.
"We believe St Margaret's should be able to continue its valuable work and are actively and urgently seeking a solution.
"I will personally meet with representatives of St Margaret's next week to discuss the best way forward."
The National Secular Society welcomed the charity regulator's ruling.
Spokesman Alistair McBay said: "Sectarian decision-making has no place in adoption arrangements, and the regulator also found that St Margaret's was discriminating against non-Catholic couples who applied to adopt.
"This kind of crude discrimination is no longer acceptable in our society - and that goes double where the discrimination is, in effect, being largely financed by the public purse."