The woman's family had wanted her life-support machine to be turned off.
Doctors had not granted their wishes as they were unsure of the legal status of the unborn child under the constitution in the Republic of Ireland.
The woman in the case was declared brain-dead on 3 December.
The court had heard that the chances of her unborn child being born alive were small.
Lawyers for the unborn child had told the court that it must be satisfied that there was no real possibility of the foetus surviving before allowing the machine to be turned off.
Lawyers for the Health Service Executive (HSE), the body which runs all public health services in the Republic of Ireland, had argued that it would be lawful to withdraw life-support in this case.
The woman is in her late 20s and has two other children.
The judge said that to "maintain and continue" the present support would "deprive her of dignity in death".
"It would subject her father, her partner and her young children to unimaginable distress in a futile exercise which commenced only because of fears held by treating medical specialists of potential legal consequences," he said.
Irish Health Minister Leo Varadkar said he would be carefully examining the ruling.
"I wish to convey my heartfelt sympathies to the family and partner of the woman at the centre of this case at this most difficult time - particularly given the season," he said.
"This case and the judgement will need to be carefully examined before I can make any further comment on it.
"In the meantime, I would ask that the privacy of this family is respected, at this so difficult and challenging time."
A judge in Dublin's High Court has ruled that a life-support machine may be switched off in the case of a brain-dead woman who is 18 weeks pregnant.