The Moudawana establishes a precise priority order for the attribution of child custody, reflecting the Islamic conception of the family while incorporating modern adaptations. Article 171 sets this order as follows: first, the mother; second, the father; third, the child's maternal grandmother. If these three primary holders are unable or unfit, the court awards custody, based on the child's best interests, to one of the closest relatives most able to assume it. The court then considers the material and moral conditions of the proposed relative, their relationship with the child, and their educational capacity.
It is important to note that the 2004 Moudawana made a significant change from prior law. Under the former 1957 Moudawana, the priority order placed the maternal grandmother before the father. The 2004 reform, by positioning the father immediately after the mother and before the maternal grandmother, recognised a more balanced parental role while maintaining the mother's primacy in custody matters. This legislative choice was welcomed as progress towards parental equality, although some commentators felt it did not go far enough.
During the marriage, hadana is exercised jointly by both parents (Article 164). It is in case of dissolution of the marriage (divorce, khol', death) that the priority order applies. When parents divorce, custody is awarded primarily to the mother, provided she meets the legal conditions set out in Article 173. If the mother is unable to exercise custody (incapacity, illness, distance), the right passes to the father, then to the maternal grandmother. The court may depart from this order if the child's interest so requires, providing reasons for its decision.
The question of custody in case of a parent's death is also addressed by the Moudawana. Article 171 provides that custody goes to the surviving parent. However, if the surviving parent does not meet custody conditions, the court awards it according to the established priority order. In practice, disputes frequently arise between the surviving parent and the deceased parent's family, particularly grandparents, often requiring the family judge's intervention.