At the end of this week, your baby's anal sphincter muscle is fully functional. This should prevent any small particles of meconium from being passed into the amniotic fluid. Meconium is first produced at 12 weeks. It is the somewhat greenish/black first poop that nine out of 10 newborn babies pass in the first 24 hours.
Meconium is formed mainly from cells discarded from the lining of the gut as it lengthens and expands, and the waste of any nutrients which have been absorbed from the swallowed amniotic fluid. It is continuously produced, slowly moving down the gut to enter the large bowel (colon) by 16 weeks. Meconium is sterile since there are no organisms inside the gut and no bowel gas is produced.