Lawyers for the young woman - who suffers from lupus and kidney failure - had argued that continuing the pregnancy would place her life at risk.
The foetus itself is missing part or all of its brain.
All abortions are prohibited in El Salvador under any circumstances.
The constitution in the majority Roman Catholic country protects the right to life "from the moment of conception".
The 22-year-old woman - referred to as "Beatriz", not her real name - is said to be in fragile health, suffering from the chronic immune disorder lupus as well as kidney failure.
Tests suggest her 26-week-old foetus is developing without a complete brain, a condition called anencephaly. Almost all babies born with this condition die before or shortly after birth.