A seriously ill woman who was denied an abortion by the Supreme Court in El Salvador has undergone a premature Caesarean section.
The 22-year-old woman, who has lupus and kidney problems, sought to end the pregnancy, which doctors said posed a serious risk to her life.
The foetus developed without a complete brain and skull and died shortly after birth.
Last week the supreme court upheld El Salvador's absolute ban on abortions.
Health Minister Maria Isabel Rodriguez said the baby had died five hours after the C-section.
Doctors decided the procedure had become necessary when the woman started having contractions on Sunday night, Ms Rodriguez said.
She insisted that the medical intervention did not contravene the court ruling.
Under the ruling, she said, "mother had to be given all the necessary protection to save her life, while analysing how long one could wait and do the utmost to save the baby's life".
It is not clear how far advanced exactly the pregnancy was, with local sources saying the woman was 24 weeks pregnant, while Reuters news agency said she was 27 weeks pregnant and Agence France Press agency reporting she had the C-section after 26 weeks of gestation.
The woman, referred to as "Beatriz", is now in a stable condition in intensive care.
Her plight had drawn international attention after the Supreme Court denied her the abortion she was seeking despite the medical risks involved in the pregnancy and the low chances of the foetus surviving beyond birth.
A medical committee at her maternity hospital, the Ministry of Health and rights groups had supported her request to terminate her pregnancy.
But the Supreme Court argued that the "the rights of the mother cannot take precedence over those of the unborn child or vice versa, and that there is an absolute bar to authorising an abortion" under the Salvadoran constitution.
El Salvador banned all types of abortion in 1999. The sentence for doctors and women violating that ban is 50 years in prison.
A non-binding resolution by the Inter-American Court of Human Rights last week called on the Salvadoran authorities to take action to save Beatriz's life.
"This pregnancy is a risk to her life, a fact that merits extreme and urgent measures to be taken to safeguard her health," the regional court based in San Jose, Costa Rica, said.
Women's rights groups in El Salvador have welcomed the decision by the country's health ministry to allow the C-section but have condemned the long wait Beatriz had to endure, which they say inflicted "unnecessary suffering".
Spokeswoman for the anti-abortion group Red Familia Claudia Handal also welcomed the outcome.
"We're happy because as we said from the beginning, it wasn't necessary to perform an abortion, the point was to respect the baby's life and to give Beatriz the care and the right to health that she deserved," she told Reuters news agency.