The corpus luteum is responsible for producing the progesterone required to maintain the pregnancy until six to seven weeks of gestation, when the placenta develops and takes over, until the baby is born approximately 40 weeks later.