Mujahid (may Allah have mercy on him) said regarding the saying of Allah Almighty: "And mothers shall breastfeed their children for two full years" [Surah al-Baqarah: 233]: This refers to divorced nursing mothers. Regarding "No mother should be harmed through her child" [Surah al-Baqarah: 233] he said: She should not refuse to breastfeed him out of spite, so that he becomes a burden on his father. Regarding "nor the one to whom the child is born, through his child" [Surah al-Baqarah: 233] he said: The father should not cause harm through his child by preventing its mother from breastfeeding it, in order to grieve her by that. Regarding "And upon the heir is the like of that" [Surah al-Baqarah: 233] he said: That is, the guardian, whoever he may be. Regarding "If they both desire weaning by mutual consent and consultation" [Surah al-Baqarah: 233] he said: Without either of them doing wrong to themselves or to their child before the two years (are complete); "then there is no blame on them." Regarding "And if you wish to have your children nursed (by others)" [Surah al-Baqarah: 233] he said: For fear of the child being neglected. Regarding "then there is no blame on you as long as you pay what you give according to what is fair" [Surah al-Baqarah: 233] he said: That is, according to the reckoning of how long the child was nursed.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب النفقات / 15738