The woman's Catholic mother earlier this week won a legal battle after doctors said the pregnancy should be terminated.
A judge on Friday gave specialists permission to terminate the pregnancy.
But Court of Appeal judges on Monday overturned that decision after the woman's mother mounted a challenge.
Judges have heard that the woman, who is in her twenties and 22 weeks pregnant, has the mental age of a child aged between six and nine.
They were told that she had been diagnosed with a "moderately severe" learning disorder and a mood disorder.
Lawyer Laura Hobey-Hamsher, who represented the woman's mother, said the woman has already chosen a name.
"There is no question that the questions faced in this case are some of the most difficult faced by judges," said Ms Hobey-Hamsher, who works for law firm Bindmans.
"Ultimately, the Court of Appeal disagreed with the analysis previously carried out, and the woman at the heart of all of this will now be able to meet the baby, who she has already named."
She went on: "All of those involved in her care can put the past behind them and turn their attention to where it is needed most: The pregnancy, and the safe delivery of a healthy baby."
Mrs Justice Lieven had initially analysed the case at a hearing at the Court of Protection, where issues relating to people who lack the mental capacity to make decisions are considered, in London on Thursday and Friday.
She concluded that an abortion would be in the woman's best interests.
Lord Justice McCombe, Lady Justice King and Lord Justice Peter Jackson overturned Mrs Justice Lieven's decision after analysing evidence at a hearing in the Court of Appeal in London.
Bosses at an NHS hospital trust responsible for the woman's care had asked Mrs Justice Lieven to let doctors perform an abortion.
Three specialists, an obstetrician and two psychiatrists, said a termination was the best option because of the risk to the woman's psychiatric health if pregnancy continued.
They said the woman's behaviour could pose a risk to a baby.
Specialists also said the child might have to go into care and taking a baby away would cause greater psychiatric harm than terminating the pregnancy.
The woman's mother was against termination and said she could care for the child.
A social worker who works with the woman said the pregnancy should continue.
Lawyers who represented the woman also said she should be allowed to give birth.
Judges heard that the "circumstances of the conception" were "unclear" and that a police investigation was ongoing.
They have ruled that the woman's daughter, who lives in the London area, cannot be identified in reports of the case. They also said the NHS hospital trust which asked for a decision, and the council which employs the social worker, cannot be named because publication of their names might create an information jigsaw which could lead to the woman's daughter's identity being revealed.
Stay up to date with the latest news stories from a Christian perspective. Sign up to our daily newsletter and receive more stories like this straight to your inbox every morning.