Supreme Court justices heard "distressing" evidence on behalf of a number of women who suffered "harrowing" experiences as a consequence of Northern Ireland's abortion laws.
By a majority of four to three, the seven-strong panel of judges ruled on Thursday that the Northern Ireland Human Rights Commission (NIHRC) had no legal standing to bring its challenge against the current legislation.
But a majority of the judges also strongly expressed their opinion that the present laws are incompatible with article 8 of the European Convention on Human Rights (ECHR) - the right for respect for private and family life.
In his ruling, Lord Mance said the court was given evidence during a hearing in October last year on behalf of a number of women.
He said the individual cases were "distressing", but were not before the court for consideration in the same way they would have been if the women concerned had brought proceedings as victims.
Three of the women, who were described by Lord Kerr as "enormously brave", described their experiences of being pregnant with babies with fatal foetal abnormalities.
Sarah Ewart, one of the three, attended court on Thursday for the ruling and said she will continue her fight for a change in the law.
She travelled from Northern Ireland for a termination in England in 2013 after a 20-week scan revealed her baby had anencephaly, which meant its brain and skull had not developed and it would either die before being born or shortly afterwards.
Ms Ewart, aged 23 at the time, told judges she was "horrified" to discover her baby would not be able to travel down the birth canal because of its condition and decided she "could not face" the prospect of a long and painful labour.
She was refused an abortion in Northern Ireland, with one doctor telling her she "wasn't going to prison for anyone", and was abused by protesters outside a family planning clinic in Belfast.
Eventually, she underwent a late-stage abortion in England, but felt "criticised" and said the process was "like a conveyor belt".
She described her experience as "devastating and at times almost overwhelming".
Speaking outside the court after the ruling, she said: "I, and we, will not stop until we can get our own medical care in our own hospitals at home.
"To Theresa May I would say 'We need change and help. This is a medical procedure that we need in our hospitals with our own medical team. Please help us now'."
She added: "I am relieved to hear the highest court in the land has recognised that Northern Ireland is in breach of human rights for people who find themselves with fatal foetal abnormality and have said that the law needs to be changed, so we will keep going until we get that change."
Supported by Amnesty International, Ms Ewart said she will now bring a case at the High Court in Belfast, seeking the declaration of incompatibility with human rights laws that the NIHRC was unable to obtain.
She added: "I'm not only doing this for me, but for every woman who may find themselves in my situation.
"We will not accept being forced on planes to access healthcare. What we need is compassion and services in Northern Ireland."
The court also heard evidence from Ashleigh Topley and Denise Phelan, who both received diagnoses of fatal foetal abnormality.
In a statement before the judges, Mrs Topley spoke of her "joy" at discovering she was pregnant in 2013, but a 20-week scan revealed her baby had a severe bone abnormality and she was told it would not survive birth.
She was refused an abortion and her daughter was stillborn at 35 weeks.
Aged 27 at the time, she faced the ordeal of people congratulating her or asking about the baby during and after her pregnancy.
Mrs Phelan, a qualified lawyer and teacher, planned an abortion in England - at a cost of £1,400 - after discovering her baby had Edwards' Syndrome.
However, she was unable to attend her appointment after becoming "incredibly ill with grief, depression and chronic migraine and vomiting".
She became even more depressed and ill as a result and thought of committing suicide.
Her baby was eventually delivered five days after it had died in her womb.
The court also heard accounts on behalf of a number of women and girls who could not be identified.
These included a woman who was raped by an abusive partner and forced to travel abroad for an abortion, a woman who was gang-raped, a mother who was prosecuted after supplying her underage daughter with abortion pills and a victim of incest who was aged under 13, who had to travel to England for a termination.