Northern Ireland's abortion law breaches the UK's human rights commitments, the High Court ruled.
The case was taken in Belfast by Sarah Ewart, who challenged the law after she was denied a termination.
The judge said she ruled in Mrs Ewart's favour as it was not right to ask another woman to relive the trauma that she had already experienced.
Mrs Ewart said the ruling was "a turning point for women" in their campaign against "outdated laws".
The judge said a formal declaration of incompatibility would not be made at this stage.
Mrs Justice Keegan made that decision in light of impending legislation, already passed at Westminster, which will decriminalise abortion if there is no deal to restore devolution in Northern Ireland by 21 October.
Members of the anti-abortion campaign group Precious Life protested outside the court during the hearing.
"It's a very sad day that the court has denied the right to life for unborn children," said director Bernie Smyth.
What are the current rules on abortion in NI?
Northern Ireland's abortion legislation is very different from the law in Great Britain.
The 1967 Abortion Act, which liberalised the rules in England, Scotland and Wales, was never extended to Northern Ireland.
Currently, a termination is only permitted in Northern Ireland if a woman's life is at risk or if there is a risk of permanent and serious damage to her mental or physical health.
Rape, incest or diagnoses of fatal fetal abnormality - where medics believe that a baby will die before, during or shortly after birth - are not grounds for a legal abortion in Northern Ireland.
Inside the courtroom
by Leanna Byrne, BBC News NI
Mrs Justice Siobhan Keegan hushed those gathered when she entered the small wooden-panelled courtroom.
The judge's summation lasted more than 30 minutes, summarising the events of six years for Sarah Ewart.
When the judge's conclusion finished on the finer legal points of a "formal declaration of incompatibility", it left many in the room confused as to what the outcome was.
But after a scramble all was made clear: Mrs Ewart had succeeded in her legal challenge.
Yet the whole time Mrs Ewart remained subdued, then left the court silently to reconvene with her legal team.
Outside, six protestors from Precious Life stood with placards.
Bernie Smyth, the group's director, had sat at the back of the court to hear the judgement.
Like Mrs Ewart, she left without a word and returned to the spot where she had tied her banner to the gates of the courts.
What happened to Sarah Ewart?
In 2013, Mrs Ewart was told she could not have a legal abortion, despite doctors saying her fetus would not survive outside the womb.
She travelled to England for a termination and later spoke to the media about the additional trauma and expense that journey had caused her family.
Since that date, she has led a high-profile campaign to change Northern Ireland's law in cases of fatal fetal abnormality.
"Today's ruling is a vindication of all those women who have fought tirelessly to ensure that we never again have to go through what I did in 2013." Mrs Ewart said.
But she added that it "should never have had to come to this" and said the case had been "a massive stress emotionally on all the family".
How did this case come to court?
Mrs Ewart took the High Court case in her own name, after a Supreme Court appeal, led by the Northern Ireland Human Rights Commission, failed last year.
A majority of Supreme Court judges had agreed Northern Ireland's existing legislation was incompatible with human rights law in cases of fatal fetal abnormality and sexual crime.
However, the judges dismissed the commission's case on a technicality, ruling that the organisation did not have the legal standing to bring such a challenge.
The judges said the case would have had more merit had it been brought by a woman pregnant as a result of sexual crime or carrying a fetus with a fatal abnormality.
Mrs Ewart later agreed to lead the challenge based on her own experience and sought a judicial review of Northern Ireland's abortion laws.
"Sarah should not have had to take this case in the first place - in 2018, the Supreme Court ruled clearly that Northern Ireland laws ran contrary to human rights standards," said Les Allamby, from the commission.
"Parliament should have changed the law then without delay."
What happens now?
This landmark case has been somewhat eclipsed by a separate intervention from Westminster MPs which could completely overhaul Northern Ireland's abortion laws.
In July, MPs voted for legislation which requires the government to liberalise abortion and extend same-sex marriage to Northern Ireland if devolution is not restored by 21 October.
Northern Ireland has been without a devolved government for almost three years.
Stormont's power-sharing coalition collapsed in January 2017 after a major row between the Democratic Unionist Party (DUP) and Sinn Féin.
At present there is little sign that there will be a resolution within the 18-day deadline.
It was this upcoming deadline that the High Court judge referred to when she ruled in favour of Mrs Ewart.
Mrs Justice Keegan said a formal declaration of Northern Ireland's incompatibility with UK human rights commitments would not be made at this stage, in light of that impending legislation.