Ruling on divorce conditions tied to the gender of children when multiple children are born simultaneously from one pregnancy:
Chapter on Explicit Divorce and Others
Al-Mughni
Book of Divorce
Primary text
If a husband states, "If you give birth to a male, you are divorced once, and if you give birth to a female, you are divorced twice," and she gives birth to both a male and a female simultaneously, three divorces occur. If they are delivered in two separate deliveries, the condition attached to the first delivery takes effect, and the wife becomes irrevocably divorced upon the second delivery, meaning the second condition does not result in divorce. This is the view held by Al-Shafi'i and the Ashab al-Ra'y, except for the opinion of Ibn Hamid.
Supporting text
If it is unclear which child was delivered first or the manner of their delivery, only one divorce occurs certainly, and the second is not incumbent. It is more pious (al-wara') to accept the second divorce as well. Al-Qadi stated that the analogy of the Madhhab (Hanbali school) requires drawing lots between the two deliveries.