MEXICO CITY — El Salvador’s highest court on Wednesday denied an appeal from a woman with a high-risk pregnancy to be allowed to undergo an abortion, upholding the country’s strict law banning abortion under any circumstances.

Beatriz, a 22-year-old woman who asked that her last name be withheld to protect her identity, has lupus and related complications that doctors say will get worse as the pregnancy, which is in its 26th week, continues, possibly leading to serious illness or even death.

Her fetus, which has anencephaly, a severe birth defect in which parts of the brain and skull are missing, has almost no chance of surviving after birth, leading her doctors to urge an abortion to protect Beatriz’s health before it deteriorates further.

But in a 4-to-1 ruling, the court cited the country’s legal “absolute impediment to authorize the practice of abortion,” and ruled that “the rights of the mother cannot be privileged over those” of the fetus.