South Korea's Constitutional Court overturned a ban on doctors telling parents the gender of unborn babies, saying Thursday the country has grown out of a preference for sons and that the restriction violates parents' right to know.

South Korea introduced the ban in 1987 to try to prevent abortions of female fetuses in a country that had traditionally favored sons in the widespread Confucian belief that males carry on family lines. Abortion has also been illegal but practiced widely.

On Thursday, the Constitutional Court said it was too restrictive to ban doctors from telling parents the gender of the unborn for the entire pregnancy because there was little chance of aborting fetuses older than six months due to risks for mothers.

"The legislation's purpose is recognized in that it helps resolve the sex-ratio imbalance and protects the fetuses' right to life," the court said in the ruling. "But it overly limits the basic rights of parents and physicians to put a blanket ban through the latter half of pregnancy."

It also said the preference for sons has lessened to a point where the ratio of newly born boys and girls in the country has almost reached the natural level of 100 girls to 106 boys.

"Considering this, we cannot but question whether the sex-ratio imbalance is a serious social problem and whether the fetus gender notification is serving as a cause for abortion," it said.

The court ordered the law be revised to reflect the ruling by the end of next year.