Scottish women will still be allowed to take abortion pills at home after a legal challenge against the move was thrown out.
Scotland became the first part of the UK to let women take the drug misoprostol at home last year.
The Society for the Protection of Unborn Children (SPUC) challenged the decision at the Court of Session.
However, judge Lady Wise has now ruled that the Scottish government's move was "not unlawful".
SPUC said it was "extremely disappointed" with the decision and that it would appeal against the ruling.
The vast majority of abortions in Scotland take place at less than nine weeks gestation, and are medical rather than surgical procedures.
The medical treatment involves taking two different drugs - first misfepristone, which blocks hormones which maintain the pregnancy, and then misoprostol, which can be taken on the same or following days.
Within an hour of taking the second tablet, women often experience heavy bleeding - usually on the way home from the clinic.
Scottish ministers moved to let women take misoprostol at home, saying this would allow them to be "in control of their treatment and as comfortable as possible during this procedure".
This already happens in other countries such as France and Sweden, and the British Pregnancy Advisory Service has been lobbying for the law in the UK to be changed.
However, pro-life group SPUC challenged the decision in Scotland's highest court, arguing that such a move contravenes the 1967 Abortion Act.
It said abortions could only legally be carried out in a medical facility, and argued that allowing women to take the tablet at home could put their health at risk.
However, Lady Wise rejected this, saying: "It seems to me that patients who self-administer medication at home may still be described as being treated by their medical practitioner, who remains in charge of that treatment."
Drawing an example to diabetics injecting themselves with insulin, she added: "Regardless of place, there is no need for a doctor to hand the medication to the woman personally."
Dismissing the challenge, the judge wrote: "I have concluded that the decision of the respondents to approve a woman's home as a place where one stage of the termination of pregnancy can be carried out is not unlawful on either of the grounds contended for by the petitioner."
John Deighan, chief executive of SPUC Scotland, said he was "extremely disappointed" with the verdict.
He said: "We maintain the belief that our arguments convincingly exposed the unlawfulness of the actions taken by the Scottish government, which are in contravention of the law.
"We will give thorough consideration of the judgement but at the forefront of our thoughts is the expectation that we will appeal the decision."
'Distress and embarrassment'
Prof Lesley Regan, president of the Royal College of Obstetricians and Gynaecologists, said the decision marked "a very significant step forward".
She urged UK Health Secretary Matt Hancock to replicate the move south of the border, saying he should "extend the same dignity and compassion to women in England".
She said: "It will allow women to avoid the distress and embarrassment of bleeding and pain during their journey home from an unnecessary second visit to a clinic or hospital.
"Ultimately, it will help to improve women's access to safe and regulated abortion care and take pressure off NHS services."